delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/10/28/08:15:31

From: "Clueless" <username_spammer_ AT sprint DOT ca>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Calculating Time-lapse (time taken between calculations)
Date: 28 Oct 1997 09:14:40 GMT
Organization: Sprint Canada Inc.
Lines: 28
Message-ID: <01bce38a$3252a400$1e0867d1@username>
References: <62ra8g$hch$1 AT news DOT interlog DOT com>
NNTP-Posting-Host: hme1-1.news.sprint.ca
Cache-Post-Path: grolsch!unknown AT spc-isp-cal-uas-1-30 DOT sprint DOT ca
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Gautam N. Lad <gautam AT interlog DOT com> wrote in article
<62ra8g$hch$1 AT news DOT interlog DOT com>...
> Hi,
> I want to time how long certain calculations/processes take, but I want
the time 
> in decimals (eg. .025230 seconds).

do this: (it works on msvc and djgpp)

#include <time.h>

void main ()
{
	clock_t 	start, 
		finish;
	double  	duration;

  	start = clock();
	
	//////////////////
	// things to be timed
	////////////////

    	finish = clock ();

	duration = (double)(finish - start) / CLOCKS_PER_SEC;
	printf( "\n%.5f seconds\n", duration );	
}

- Raw text -


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