Is there a way to benchmark crypto libraries so t开发者_如何转开发hat the results are hardware independent?
No. Many libraries will make use of various CPU facilities in order to speed up their algorithms, thereby making hardware-independent benchmarks impossible.
To benchmark algorithms on x86 machine in a frequency independent way we use to count CPU cycles rather than time. Not sure if ARM suport such feature, if so, you can have solve your problem using some conditional code like:
uint64_t get_cycles()
{
#ifdef _INTEL_X86
// return CPU cycle count with x86 specific code
// read tim stamp counter instruction rdtsc() for instance
#endif
#ifdef _ARM
// return CPU cycle count with ARM specific code
#endif
}
uint64_t start, stop, tot_cycles;
start = get_cycles();
// code to benchmark
stop = get_cycles()
tot_cycles = stop - start;
Hope this might help.
Use different hardware environments and calculate averages. I guess you'll also find useful information which lib suits your needs best on the net without doing benchmarks yourself.
精彩评论