Benchmark是Google一个用来对代码片段进行基准测试的库,类似单元测试,例如:
#include<benchmark/benchmark.h>staticvoidBM_SomeFunction(benchmark::State&state){//Performsetupherefor(auto_:state){//ThiscodegetstimedSomeFunction();}}//RegisterthefunctionasabenchmarkBENCHMARK(BM_SomeFunction);//RunthebenchmarkBENCHMARK_MAIN();
评论