ftp.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/02/10/20:45:55

From: DJ Delorie <dj AT delorie DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: how to reset clock()
Date: 10 Feb 1998 20:39:17 -0500
Organization: DJ Delorie/DJGPP Support
Lines: 15
Message-ID: <xnvhumapiy.fsf@delorie.com>
References: <34E0B017 DOT 506A AT quantum DOT de>
NNTP-Posting-Host: delorie.com
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Tom Chojnacki <chojnack AT quantum DOT de> writes:
> I want to measure time intervals in which some function executes itself.
> I used clock() function which returns time which elapsed since first
> call to clock(). But how can I reset the clock() to measure another time
> interval and not time since the first call again.

You don't have to reset it.  Just save the return value from before,
and subtract it from the new one:

	before = clock();
	do_something();
	after = clock();
	elapsed = after - before;

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019