4.14. Timing Cryptographic Primitives
Problem
You want to compare the efficiency of two similar cryptographic primitives and would like to ensure that you do so in a fair manner.
Solution
Time operations by calculating how many cycles it takes to process each byte, so that you can compare numbers across processors of different speeds more fairly.
Focus on the expected average case, best case, and worst case.
Discussion
When you’re looking at timing information, you usually have one of two motivations: either you’re interested in comparing the performance of two algorithms, or you’d like to get a sense of how much data you’ll actually be able to pump through a particular machine.
Measuring bytes per second is a useful thing when you’re comparing the performance of multiple algorithms on a single box, but it gives no real indication of performance on other machines. Therefore, cryptographers prefer to measure how many processor clock cycles it takes to process each byte, because doing so allows for comparisons that are more widely applicable. For example, such comparisons will generally hold fast on the same line of processors running at different speeds.
If you’re directly comparing the speed of an algorithm on a 2GHz Pentium 4 against the published speed of the same algorithm run on a 800 MHz Pentium 3, the first one will always be faster when measured in bytes per second. However, if you convert the numbers from bytes per second to cycles per byte, you’ll see that, if you run the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access