Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
C

CodingStyle

@CodingStyle
About
Posts
3
Topics
2
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • can't upload avatar
    C CodingStyle

    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

    Site Bugs / Suggestions sysadmin windows-admin help

  • Estimate time of execution c-function execution
    C CodingStyle

    Thank you!

    C / C++ / MFC linux algorithms performance help

  • Estimate time of execution c-function execution
    C CodingStyle

    Hello 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.

    C / C++ / MFC linux algorithms performance help
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups