void fun_(int b) // void 空类型,也就是不能保持任何的数据 { printf("b = %d\n",b); fun_1(); // 在函数内调用其他函数 return; // 这个return仅仅作为函数的结束标志,不会返回任何的数值 }
int main(int argc, char const *argv[]) { printf("%s: %s@%d: %s\n", PRJ_NAME, __FILE__,__LINE__ , __func__ ); fun_1(); fun_2(); printf("submod 1 = %d, submod 2 = %d\n", SUB_MOD1, SUB_MOD2 ); return 0; }
void CPUBenchmark::getProcedureOverhead(vector<double> &result){ uint64_t totalTime = 0; uint64_t start, end; //0 argument warmup(); for (int i = 0; i < TIMES; i++) { start = rdtscStart(); fun_0(); end = rdtscEnd(); totalTime += (end - start); } result[0] = (double)totalTime / (double)TIMES; //1 argument warmup(); totalTime = 0; for (int i = 0; i < TIMES; i++) { start = rdtscStart(); fun_1(1); end = rdtscEnd(); totalTime += (end - start); } result[1] = (double)totalTime / (double)TIMES; //2 argument warmup(); totalTime = 0; for (int i = 0; i < TIMES; i++) { start = rdtscStart(); fun_2(1, 2); end = rdtscEnd(); totalTime += (end - start); } result[2] = (double)totalTime / (double)TIMES; //3 argument warmup(); totalTime = 0; for (int i = 0; i < TIMES; i++) { start = rdtscStart(); fun_3(1, 2, 3); end = rdtscEnd(); totalTime += (end - start); } result[3] = (double)totalTime / (double)TIMES; //4 argument warmup(); totalTime = 0; for (int i = 0; i < TIMES; i++) { start = rdtscStart(); fun_4(1, 2, 3, 4); end = rdtscEnd(); totalTime += (end - start); } result[4] = (double)totalTime / (double)TIMES; //5 argument warmup(); totalTime = 0; for (int i = 0; i < TIMES; i++) { start = rdtscStart(); fun_5(1, 2, 3, 4, 5); end = rdtscEnd(); totalTime += (end - start); } result[5] = (double)totalTime / (double)TIMES; //6 argument warmup(); totalTime = 0; for (int i = 0; i < TIMES; i++) { start = rdtscStart(); fun_6(1, 2, 3, 4, 5, 6); end = rdtscEnd(); totalTime += (end - start); } result[6] = (double)totalTime / (double)TIMES; //7 argument warmup(); totalTime = 0; for (int i = 0; i < TIMES; i++) { start = rdtscStart(); fun_7(1, 2, 3, 4, 5, 6, 7); end = rdtscEnd(); totalTime += (end - start); } result[7] = (double)totalTime / (double)TIMES; }