Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

[c++] get system time

Posted on 2007-11-26
2
Medium Priority
?
5,814 Views
Last Modified: 2008-02-01
I need to benchmark some of my function to see how long it takes for them to run.


is it possible to do this?

time = gettime()


cou << gettime() - time ;
0
Comment
Question by:Troudeloup
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 2000 total points
ID: 20354340
if you want only the difference in seconds, you can use time() function:

time_t t1 = time(NULL);
//do some tasks here
time_t t2 = time(NULL);

cout << "Lapse:" << (t2-t1) << "seconds" << endl;
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 20354366
for milliseconds use GetTickCount();

DWORD t1 = GetTickCount();
//do some tasks here
DWORD t2 = GetTickCount();

cout << "Lapse:" << (t2-t1) << "miliseconds" << endl;
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question