Created
February 5, 2012 09:13
-
-
Save visualzhou/1744312 to your computer and use it in GitHub Desktop.
RWLock and Mutex Performance Test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Tested on CIMS energon3 server, 8 cores. The code is in branch mutex_test. | |
CPU Time (by std::clock()) | |
========================== | |
+ RWLock | |
Running Concurrent(Producer): Running time: 2.01 | |
PASSED | |
Running Concurrent(Consumer): Running time: 0.96 | |
PASSED | |
Running Concurrent(ReadWrite): Running time: 2.33 | |
PASSED | |
Running Concurrent(Lookup): Running time: 12.95 | |
PASSED | |
+ Mutex | |
Running Concurrent(Producer): Running time: 1.95 | |
PASSED | |
Running Concurrent(Consumer): Running time: 0.53 | |
PASSED | |
Running Concurrent(ReadWrite): Running time: 0.97 | |
PASSED | |
Running Concurrent(Lookup): Running time: 15.56 | |
PASSED | |
Wall-clock Time (by gettimeofday()) | |
=================================== | |
+ RWLock | |
Running Concurrent(Producer): Running time: 1.48686 | |
PASSED | |
Running Concurrent(Consumer): Running time: 0.618758 | |
PASSED | |
Running Concurrent(ReadWrite): Running time: 0.263542 | |
PASSED | |
Running Concurrent(Lookup): Running time: 1.83095 | |
PASSED | |
+ Mutex | |
Running Concurrent(Producer): Running time: 1.48389 | |
PASSED | |
Running Concurrent(Consumer): Running time: 0.416416 | |
PASSED | |
Running Concurrent(ReadWrite): Running time: 0.214367 | |
PASSED | |
Running Concurrent(Lookup): Running time: 13.3602 | |
PASSED | |
Conclusion | |
========== | |
+ Even the two approaches cost similar CPU time, but concurrent lookup test shows | |
the performance improvement of parallel execution is significant and the speed-up is 7.3. | |
+ Another interesting thing worth noting is the overhead of reader/writer lock | |
where mutual exclusion is necessary. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment