Determine process time in microseconds
Can I ask what is the simplest method to determine the time it takes to execute specific process (within a program) with microsecond precision?
I've looked at the "time_val" command but couldn't really understand how it works. An example is given below. Can anyone please advise me?
Thanks for any help in advance.
int data =
1, 2, 3,
4, 5, 6,
size_t obj_size = sizeof(int);
size_t obj_cnt = sizeof(data)/sizeof(int);
char *filename = "output.dat";
p_file = fopen(filename, "w");
// Clock start time (t1)
fwrite(&data, obj_size, obj_cnt, p_file);
//Clock end time (t2)
// Do a subtraction (t2-t1)