#include // symbolic constants #include // general utilities #include // printf #include // gettimeofday, gethrtime #include // uname // // Purpose: Measure the average execution time of the uname(2) // system call and the stub function call using gethrtime(3C) or // gettimeofday(3C) depending on the OS. Run each case 3 times. // // Usage: timeit > timeit.out # produce raw data // timeit.sh < timeit.out > timeit.txt # beautify output // // Build: g++ -o timeit timeit.c // const int LIMIT = 1000000; // limit on N void stub (void) { /* null function */ } int main (int argc, char *argv[]) { char which[2] = { 'f', 's' }; for (int i=0; i<2; i++) { // each call type for (int N=10; N<=LIMIT; N*=10) { // N = 10, 100, ... , LIMIT double tavg; for (int j=0; j<3; j++) { // do 3 times int64_t tbegin, tend; // in nanoseconds char tag; if (which[i] == 'f') { for (int k=0; k