Something bad happened We're not sure what, but we have a few guesses. Problem: Illegal characters in path. Ticket: 0 Server: Web03 Windows Server 2008 Firefox 38.0.5
CodingStyle
Posts
-
can't upload avatar -
Estimate time of execution c-function executionThank you!
-
Estimate time of execution c-function executionHello all! I need help. I need to estimate function execution time in under Linux OS. I guess that it's right way to estimate code/algorithm performance. I'm trying, something like this:
#include #include #include void test(){
int i;int s=0;for(i=1; i<1000000; i++){s+=sin(i)/i;}
}
float timedifference_msec(struct timeval t0, struct timeval t1)
{
return (t1.tv_sec - t0.tv_sec) * 1000.0f + (t1.tv_usec - t0.tv_usec) / 1000.0f;
}int main(void)
{
struct timeval t0;
struct timeval t1;
float elapsed;
gettimeofday(&t0, 0);
f1();
gettimeofday(&t1, 0);
elapsed = timedifference_msec(t0, t1);
printf("Code executed in %f milliseconds.\n", elapsed);
return 0;
}. But It's wall clock, I'm not sure that I can estimate performance by this way, besides, I need approach which will allow to measure time of each function which I choose. I've heard that there is approach to use CPU-time.