int main(int argc, char *argv[]) { unsigned long long time; long long timeS; time = getMeasureOverhead(); printf("Measurement overhead is %llu cycles\n", time); time = getLoopOverhead(); printf("Loop overhead is %llu cycles per iteration\n", time); long long callAvgs[8]; getProcedureCallOverhead(callAvgs); printf("Procedure call overhead:\n"); printf("0 args - %lli\n", callAvgs[0]); printf("1 args - %lli\n", callAvgs[1]); printf("2 args - %lli\n", callAvgs[2]); printf("3 args - %lli\n", callAvgs[3]); printf("4 args - %lli\n", callAvgs[4]); printf("5 args - %lli\n", callAvgs[5]); printf("6 args - %lli\n", callAvgs[6]); printf("7 args - %lli\n", callAvgs[7]); timeS = getSystemCallOverhead(); printf("Syscall overhead is %lli cycles\n", timeS); unsigned long long threadRun = getSingleThreadRunOverhead(); printf("Thread run overhead is %llu cycles\n", threadRun); unsigned long long procRun = getSingleProcessRunOverhead(); printf("Process run overhead is %lli cycles\n", procRun); timeS = getThreadContextSwitchOverhead(threadRun); printf("Thread context switch overhead is %llu cycles\n", timeS); timeS = getProcessContextSwitchOverhead(procRun); printf("Process context switch overhead is %llu cycles\n", timeS); exit(1); }
void CPUBenchmark::measurementOverhead(fstream &file) { cout << "1. Measurement overhead starts:" << endl; double overhead; double sum = 0; cout << "1.1 Get read overhead: "; file.open(READ_OVERHEAD_FILE, ios::out); if(file.is_open()) { for(int i = 0; i < OP_TIMES; i++) { overhead = getReadOverhead(); file << overhead << "\n"; sum += overhead; } cout << (sum / OP_TIMES) << " cycles" << endl; file.close(); } else { cout << "Can't open file-" << READ_OVERHEAD_FILE << endl; } cout << "1.2 Get loop overhead:" << endl; file.open(LOOP_OVERHEAD_FILE, ios::out); if(file.is_open()) { int LOOP_TIMES_ARRAY[15] = {0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192}; for(int i = 0; i < 15; i++) { overhead = 0; int times = 0; int loopCounts = 0; if(i == 0) { times = TIMES; loopCounts = TIMES; } else { times = TIMES / LOOP_TIMES_ARRAY[i]; loopCounts = times * LOOP_TIMES_ARRAY[i]; } for(int j = 0; j < times; j++) { overhead += getLoopOverhead(LOOP_TIMES_ARRAY[i]); } file << LOOP_TIMES_ARRAY[i] << " " << overhead / times << " "; cout << "Loop #" << LOOP_TIMES_ARRAY[i] << ": " << overhead / times << " "; if(i != 0) { file << (double) overhead / loopCounts << "\n"; cout << (double) overhead / loopCounts << " cycles" << endl; } else { file << (double) overhead / times << "\n"; cout << (double) overhead / times << " cycles" << endl; } } file.close(); } else { cout << "Can't open file-" << LOOP_OVERHEAD_FILE << endl; } }