Review your favorite Linux distribution.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 02-14-2007, 05:06 AM   #1
LQ Newbie
Registered: Nov 2006
Posts: 6

Rep: Reputation: 0
using sleep() and time() commands together in c++

clock_t start, finish;


above doesn't seem to add sleep time which is 3 seconds.
Old 02-14-2007, 07:12 AM   #2
Registered: Jun 2006
Location: Mariposa
Distribution: Slackware 9.1
Posts: 938

Rep: Reputation: 30
clock() returns not the elapsed time (wall clock time), but the processor time; that is, the amount of time that the process has spent actually performing computation of some sort. Waiting on I/O doesn't count. Sleeping (more precisely, sleep()ing) doesn't count either.

That's why you probably got a duration of 0 seconds.

If you want a simple measure of elapsed time, see:

man 2 time
If you want something almost as simple but more precise, see:

man 2 gettimeofday
Hope this helps.

Last edited by; 02-14-2007 at 07:13 AM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
can ssh execute multiple commands at the same time? Singist Linux - Networking 2 04-04-2006 09:14 AM
Searching for Server (BOOTP/DHCP) <sleep> <sleep> .. .. Eileen Linux - Networking 12 10-21-2005 01:14 AM
Commands executed at boot time Johnburrell Linux From Scratch 3 09-18-2005 01:56 PM
Time commands from command line ToothlessRebel Linux - Newbie 1 03-09-2005 10:52 AM
how to let system to sleep at certain time? taoweijia Fedora 3 07-08-2004 04:05 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:25 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration