Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C 

C++ Timer - How can I make this more efficiently?

I know this is probably the most shit program you've ever seen, but it is all I am currently capable of. This was made completely from scratch, without looking anything up. It took me about 20 minutes (had some problems with the logic) but I got it to work technically like a timer, although it is very inefficient (even I know this).

But I don't know how to make it like a C++ pro would.. any suggestions on improvement?

Here is the pastebin code source: HERE
At first thought, use boost it has a simple way to manage time.
edit..
http://www.boost.org/doc/libs/1_55_0/doc...e_duration

...or

PHP Code

<?php 
clock_t start 
= clock();
// ...
clock_t end = clock();
double elapsed = double(end - start) / CLOCKS_PER_SEC; 
RtlCreateIrlObjectA
(Oct 8, 2014 06:35 PM)Qmz_ Wrote:  ...or

PHP Code

<?php 
clock_t start 
= clock();
// ...
clock_t end = clock();
double elapsed = double(end - start) / CLOCKS_PER_SEC; 

Can you elaborate on that? Please, I am a beginner. Explain to me what that does, and how I can replace my code with it.
(Oct 8, 2014 07:42 PM)Silent Sweat Wrote:  Can you elaborate on that? Please, I am a beginner. Explain to me what that does, and how I can replace my code with it.

What is there to elaborate on? The code is self explanatory. It takes the current measurement of time, // ... indicates some kind of code that takes time to execute, and an end measurement of time is stored in a variable. To find the time elapsed, it's the delta between these 2 calculated values, and the macro CLOCKS_PER_SEC is a defined value for the "clocks per second", thus elapsed is a measurement of elapsed seconds.
Getting Started: C/C++
[C/C++/.NET/x86 ASM - Automation Programmer]


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C] by pmtobefriendOct 6, 2018 08:54 PM 4 224 Oct 6, 2018 08:54 PM
Last Post: Auriana
[C#] by trueFeb 27, 2018 03:25 AM 13 640 Feb 27, 2018 03:25 AM
Last Post: cocaine_monkey
[Shell] by Elite Hacker 69Dec 24, 2015 04:46 PM 3 279 Dec 24, 2015 04:46 PM
Last Post: b00st3d