博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ceph_perf_local
阅读量:4215 次
发布时间:2019-05-26

本文共 2191 字,大约阅读时间需要 7 分钟。

在ceph 源码ceph-master\ceph-master\src\test\CMakeLists.txt 中定义了一个ceph_perf_local的可执行文件,用于测试不同平台对ceph性能的影响#ceph_perf_localadd_executable(ceph_perf_local   perf_local.cc  perf_helper.cc)if(HAVE_SSE)  set(PERF_LOCAL_FLAGS ${SSE3_FLAGS})endif(HAVE_SSE)if(HAVE_NEON)  set(PERF_LOCAL_FLAGS ${ARM_NEON_FLAGS})endif(HAVE_NEON)if(PERF_LOCAL_FLAGS)  set_target_properties(ceph_perf_local PROPERTIES COMPILE_FLAGS    ${PERF_LOCAL_FLAGS})endif()target_link_libraries(ceph_perf_local os global ${UNITTEST_LIBS})从makefile中可以看出ceph_perf_local的源文件有两个,分别是perf_local.cc/perf_helper.cc.其编译好的执行bin的name为ceph_perf_local,从makefile中同样可以看出可以使用x86的sse或者arm的neon 指令来加速这个tool的入口函数如下:int main(int argc, char *argv[]){  vector
args; argv_to_vec(argc, (const char **)argv, args); auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0); common_init_finish(g_ceph_context); Cycles::init(); bind_thread_to_cpu(3); #测试命令可以带一个参数,如果不带参数的话,则测试所有的item项 if (argc == 1) { // No test names specified; run all tests. for (size_t i = 0; i < sizeof(tests)/sizeof(TestInfo); ++i) { run_test(tests[i]); } } else { // Run only the tests that were specified on the command line. for (int i = 1; i < argc; i++) { bool found_test = false; for (size_t j = 0; j < sizeof(tests)/sizeof(TestInfo); ++j) { if (strcmp(argv[i], tests[j].name) == 0) { found_test = true; run_test(tests[j]); break; } } if (!found_test) { int width = printf("%-24s ??", argv[i]); printf("%*s No such test\n", 32-width, ""); } } }}从main函数中可以看出测试的item项在tests 这个数组中TestInfo tests[] = { {"atomic_int_cmp", atomic_int_cmp, "atomic_t::compare_and_swap"}, {"atomic_int_inc", atomic_int_inc, "atomic_t::inc"},}}这里以atomic_int_inc的测试为例double atomic_int_inc(){ int count = 1000000; #定义一个原子变量 std::atomic
value = { 11 }; #对原子变量操作前获取时间 uint64_t start = Cycles::rdtsc(); #对这个原子变量自加1000000 for (int i = 0; i < count; i++) { value++; } #原子变量自加完成后,读取时间 uint64_t stop = Cycles::rdtsc(); // printf("Final value: %d\n", value.load()); #计算本次原子变量自加占用的时间 return Cycles::to_seconds(stop - start)/count;}

转载地址:http://pjnmi.baihongyu.com/

你可能感兴趣的文章
cocos2dx 2.2.6编译记录(1)
查看>>
makefile学习网站
查看>>
C 编写lua模块(1)
查看>>
Lua教程:Lua调用C/C++函数(4)
查看>>
win下创建win32控制台工程,执行lua脚本
查看>>
cocos2dx android启动错误
查看>>
eclipse: android rename package name
查看>>
cocos2dx c++调用java思想
查看>>
cocos2dx lua Node节点 私有数据存取
查看>>
lua math.ceil math.ceil
查看>>
cocos2dx CCNode计算node的大小
查看>>
cocos2dx 布局记录(1)
查看>>
lua 多行注释和取消多行注释
查看>>
缩放系数计算
查看>>
cocos2dx --- 按钮点击居中放大
查看>>
cocos2dx menu位置计算
查看>>
cocos2dx资源加载机制(同步/异步)
查看>>
cocos2dx C++调用java -- 字符串传递
查看>>
git学习网站
查看>>
JavaScript 学习网站
查看>>