Math Is Fun Forum

  Discussion about math, puzzles, games and fun.   Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ • π ƒ -¹ ² ³ °

You are not logged in.

#1 2011-12-17 07:16:39

model
Member
Registered: 2011-08-10
Posts: 142

Understanding Time of programing code in c++

Hi ,

I get the time of each line of code of my program .

Program :

cout<<" timeBeginPeriod : " << timeBeginPeriod(1) <<endl; //Add Winmm.lib in Project
    cout<<" start Time : " << ( (double)GetTickCount() )/1000<<endl;
    cout<<" Hi "<< ( (double)GetTickCount() )/1000<<endl;
    cout<<" Hi , 123 456 "<< ( (double)GetTickCount() )/1000<<endl;

Note : GetTickCount()  give me number of milisecs . ./


And i get this

timeBeginPeriod : 0
start Time : 137809
Hi 137809
endTimer : 0

Which mean , each line of code taking time  " 137809 " in secs .
My question is What does mean by 137809 . Does it mean its taking that its taking 17 secs  and 809 milisec ?


Maths is Doctor that make our life easy .. smile smile

https://www.facebook.com/groups/Maths.GIS/

Offline

#2 2011-12-17 07:24:07

model
Member
Registered: 2011-08-10
Posts: 142

Re: Understanding Time of programing code in c++

model wrote:

Hi ,

I get the time of each line of code of my program .

Program :

cout<<" timeBeginPeriod : " << timeBeginPeriod(1) <<endl; //Add Winmm.lib in Project
    cout<<" start Time : " << ( (double)GetTickCount() )/1000<<endl;
    cout<<" Hi "<< ( (double)GetTickCount() )/1000<<endl;
    cout<<" Hi , 123 456 "<< ( (double)GetTickCount() )/1000<<endl;

Note : GetTickCount()  give me number of milisecs . ./


And i get this

timeBeginPeriod : 0
start Time : 137809
Hi 137809
endTimer : 0

Which mean , each line of code taking time  " 137809 " in secs .
My question is What does mean by 137809 . Does it mean its taking that its taking 17 secs  and 809 milisec ?

I think its means 20sec and 809 milisec . Right ?
if  so that mean in c++ each line of code take 20 secs and 809 mili secs .  hmmmm ............


Maths is Doctor that make our life easy .. smile smile

https://www.facebook.com/groups/Maths.GIS/

Offline

#3 2011-12-17 08:50:30

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Understanding Time of programing code in c++

Hi model;

That is not your exact output, what happened to the 123456?

Also 137809 is 137 seconds and 809 milliseconds.

Something is not right but GetTickCount()  is incremental so if two of them are the same that means 0 time occurred between two lines.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

#4 2011-12-17 08:56:54

model
Member
Registered: 2011-08-10
Posts: 142

Re: Understanding Time of programing code in c++

bobbym wrote:

Hi model;

That is not your exact output, what happened to the 123456?

Also 137809 is 137 seconds and 809 milliseconds.

Something is not right but GetTickCount()  is incremental so if two of them are the same that means 0 time occurred between two lines.

ahh hy 123456 is inside cout just  for showing some output .that is not time .


Maths is Doctor that make our life easy .. smile smile

https://www.facebook.com/groups/Maths.GIS/

Offline

#5 2011-12-17 09:00:43

model
Member
Registered: 2011-08-10
Posts: 142

Re: Understanding Time of programing code in c++

Actually , i have moving objects presented in video . i calculated  distance .   I  need to find speed . I am thinking that where should i add statement to get time and use it for speed calculation,. for deciding that i need to understand time meaning w,r,t  code. 

Well could you  please tell me that how  are u say : 137809 is 137 seconds and 809 milliseconds.  ?


Maths is Doctor that make our life easy .. smile smile

https://www.facebook.com/groups/Maths.GIS/

Offline

#6 2011-12-17 09:05:49

bobbym
bumpkin
From: Bumpkinland
Registered: 2009-04-12
Posts: 109,606

Re: Understanding Time of programing code in c++

The GetTickCount() function if I remember counts in milliseconds from the start of the machine.

So there are 137809 milliseconds, when you divide by 1000 ( there are 1000 milliseconds in a second ) you will get 137 seconds and 809 milliseconds.


In mathematics, you don't understand things. You just get used to them.
If it ain't broke, fix it until it is.
Always satisfy the Prime Directive of getting the right answer above all else.

Offline

Board footer

Powered by FluxBB