measuring running time of a C++ code

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mina minol
    New Member
    • Jan 2012
    • 1

    #1

    measuring running time of a C++ code

    Can somenone tell me, when I use C++ clock(), i get same value for start and finish.

    //the code
    start=clock();

    my code

    finish=clock();

    cout<<double(fi nish-start)/CLOCK_PER_SEC;//I get 0 here
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    Probably your code is taking much less than a second to run.

    Normally to measure the speed of simple code you run it multiple times, 1000000 say, and get the time for that number of runs.

    Comment

    Working...