对于 c 中的函数 system(),如果您试图查看您运行的命令是如何执行的,它会影响硬件计数器吗例如,假设我使用 Performance API(PAPI) 并且程序是预编译的矩阵乘法应用程序
PAPI_start_counters();
system("./matmul");
PAPI_read_counters();
//Print out values
PAPI_stop_counters();
我显然遗漏了一点,但我试图找出的是,通过使用所述计数器来获得正在运行的程序的性能是可能的。从我的测试中,我会得到如下所示的狂野数字。他们显然错了,只是想找出原因
Total Cycles =========== 140733358872510
Instructions Completed =========== 4203968
Floating Point Instructions =========== 0
Floating Point Operations =========== 4196867
Loads =========== 140733358872804
Stores =========== 4204037
Branches Taken =========== 15774436