Created
October 16, 2016 14:22
-
-
Save fcamel/7ee4127eda7bfed9e3fd08820eb9dc93 to your computer and use it in GitHub Desktop.
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
| $ g++ -std=c++11 count_bits.cpp -o count_bits -O3 && ./count_bits | |
| count_directly : sum=7998166000, duration=3315520721 ns | |
| count_by_table : sum=7998166000, duration=607687929 ns | |
| count_by_table8 : sum=7998166000, duration=694708929 ns | |
| count_by_bit_operation: sum=7998166000, duration=241576894 ns | |
| count_by_popcnt : sum=7998166000, duration=69186289 ns |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for your article that shares this experiment. The algorithm of bit operation is amazing and impressive.
It is interesting that count_by_table8 is no faster than count_by_table in your result, since the table size are greatly reduced and should fit data cache well.
Then I did the same experiment on my laptop.
Here is my result https://gist.github.com/arcbbb/634323d2295a4beab1c080e0dc7bc2af
just to share the information with you that my laptop shows different result. quite interesting.