Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Pure c++ question

Author
Message
Varix
18
Years of Service
User Offline
Joined: 23rd May 2006
Location:
Posted: 6th Sep 2006 01:56
Ive decided to start learning standard c++, and have stumbled upon a problem. I would Like to use a timer to time how long the program is running, but not based of the cpu speed. isn't there like a way to call from the system clock?
Varix
18
Years of Service
User Offline
Joined: 23rd May 2006
Location:
Posted: 6th Sep 2006 03:43
nobody knows???
Acolyte
18
Years of Service
User Offline
Joined: 3rd Feb 2006
Location:
Posted: 6th Sep 2006 07:06
well if you use the SDK (which happens to the forum your on) then there should be a timer function in the documentation. Otherwise you'll have to figure out some way to access the clock directly from the system, which i don't know how to do in regular c++.

Windows XP Home Ed. SP/2 ---> GeForce FX 5500 - 256MB
160 GB HD ---> 1 Gig RAM
OSX Using Happy Dude
21
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 6th Sep 2006 11:07
Aside from the ones in the GSDK, there is also the C function time, or you can call the API function.

Come to the last Unofficial DBPro Convention - register interest by Saturday 2/9/06 (http://convention.logicstudios.net/)
Demoing at the last Chichester Convention : Humans On A Planet
JohnD99
18
Years of Service
User Offline
Joined: 4th Sep 2006
Location:
Posted: 6th Sep 2006 12:51
I'm going to go out on a limb and guess that you are using windows... so you can use GetTickCount() to return the time your program has been running in milliseconds.
Varix
18
Years of Service
User Offline
Joined: 23rd May 2006
Location:
Posted: 6th Sep 2006 23:41
and the gettickcount() is in time.h? and based on time, not cpu speed?


and im using bloodshed ide, u guys seem to know what ur doing with programming, so i posted here...
JohnD99
18
Years of Service
User Offline
Joined: 4th Sep 2006
Location:
Posted: 7th Sep 2006 01:53
I believe it is windows.h... it is automatically included when I compile in Visual C++ 2005... not sure about the compiler/ide you are using.
JohnD99
18
Years of Service
User Offline
Joined: 4th Sep 2006
Location:
Posted: 7th Sep 2006 09:58
also it is GetTickCount() - capitalized like that.
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 7th Sep 2006 23:17
From MSDN:

Quote: "The GetTickCount function retrieves the number of milliseconds that have elapsed since the system was started"


To get the amount of time your program has been running, you can record the value from GetTickCount() at the very start of your program. Then when you need to know how long is has been running, you call GetTickCount() again and subtract the first value - that's the answer in milliseconds.

Oh, and the dbTimer() function is simply a rename of the GetTickCount() function.

Varix
18
Years of Service
User Offline
Joined: 23rd May 2006
Location:
Posted: 7th Sep 2006 23:40
Thank you so much everyone, I think I got it now.
Varix
18
Years of Service
User Offline
Joined: 23rd May 2006
Location:
Posted: 8th Sep 2006 02:59
oh and, in c++, theres no need to have the header files after compiled to run, is there? for example, i make a program that uses iostream.h and give the exe to a friend, does he need iostream.h on his pc?
APEXnow
Retired Moderator
21
Years of Service
User Offline
Joined: 15th Apr 2003
Location: On a park bench
Posted: 8th Sep 2006 03:05
Nope, header files are only used during compiling.

.lib files are only used during linking.

monotonic
18
Years of Service
User Offline
Joined: 24th Mar 2006
Location: Nottinghamshire, England
Posted: 8th Sep 2006 03:05
No once its compiled into a PE there's no need to bundle the header files with it.

I know the voices aren't real, but they have good ideas!
Gen
20
Years of Service
User Offline
Joined: 6th Jul 2004
Location: Oklahoma, USA
Posted: 8th Sep 2006 03:07 Edited at: 8th Sep 2006 03:08
damn, two two post before i answered

Windows XP Pro Service Pack 2, Pentium 4 3.0 GHz, 2048 MB Daul Channeled PC3200 Ram, ATI Radeon X700 Pro 256 MB

Login to post a reply

Server time is: 2024-11-19 08:48:45
Your offset time is: 2024-11-19 08:48:45