Hi there,

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?

Code:
#include <stdio.h>
int main()
{
    int data[2][3] =
    {
       1, 2, 3,
       4, 5, 6,
    };

    size_t obj_size = sizeof(int);
    size_t obj_cnt = sizeof(data)/sizeof(int);
    char *filename = "output.dat";
    FILE *p_file;

    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)

    fclose(p_file);
 
    return 0;
}
Thanks for any help in advance.

Ken