I am working on Ubuntu, and I want to time an assembler function in C.
Thats my code:
#include <time.h> #include <stdio.h> #include <unistd.h> extern void assembler_function(char*,int); int main(){ char *text1 = "input.txt"; clock_t start=clock(); sleep(3); // used for test //assembler_function(text1,0); clock_t stop=clock(); //printf("%d %f\n",(int)stop,((float)stop)/CLOCKS_PER_SEC); printf("Time : %f \n",(double)start/CLOCKS_PER_SEC); printf("Time : %f \n",(double)stop/CLOCKS_PER_SEC); printf("Time : %f \n",(double)(stop-start)/CLOCKS_PER_SEC); return 0; } The results are :
Time : 0.000000
Time : 0.000000
Time : 0.000000