I’m having a tough time producing a scenario that will display a time difference between invocation of a simple local function vs. the same function but within a child process. The particular function I’m testing shows no difference (time = 0) for the difftime(x,y) function for both the local function and the child process. Can someone generalize potential time differences in these two methods of doing the same thing?
As a side note, I tried doing each task 1000 times and then dividing time by 1000, but even then the time returned is 0. For example, I have:
time(&start);
for(int i = 0; i<1000; i++){
reply[i] = my_channel.send_request("hello");
}
time(&end);
time_req_1 = difftime(end,start);
And time returned for “time_req_1” = 0.
I only put this code segment in just in case I’ve done something incorrect.
You have to remember that the resolution for
timeis in seconds. A common way to time e.g. a function call is to useclock:Edit: If you want even better accuracy and resolution than
clockcan provide, see the comment by Jonathan Leffler to your question.