timing function calls in C? (recvfrom() on Pentium II)
Anyone know how I can measure how long it takes for a function to execute?
I'm writing a server application in C that calls recvfrom() to grab UDP packets. On the crappy old Pentium II I'm running it on, recvfrom() takes ~15 ms to execute. I can measure this by looking at the time in between serial port transmissions on either side of the call with an oscilloscope. However, I'd like a better method, so I can test it on multiple machines without dragging the scope around. I'm running OpenBSD 3.4. Suggestions? By the way, does 15 ms seem slow for a recvfrom() call on a Pentium II, 233 MHz? Thanks, Pingswept |
Code:
int main(void) |
That seems easy enough.
Thanks, Itsyou86! |
I have a similar need for code like this.
When I tried compiling the following: Code:
#include <stdio.h> Code:
$ gcc -o test main.c |
Found it...
Code:
printf("Start time: %d.%06d\n", t1.sec, t1.usec); Code:
printf("Start time: %d.%06d\n", t1.tv_sec, t1.tv_usec); |
All times are GMT -5. The time now is 05:29 PM. |