🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #6893

Re: get time problem

#6893
From: Bob Gonder
Date: Thu, 31 Mar 2005 17:08
28 lines
2006 bytes
Alex Liu wrote:

>I feel strange that the time is the same for a period of time and over and
>over again. Is this normal?

Could be, if your threads are fast.
Remember that these days, 1ms == 2 to 3 million instructions.

>And i found that the time difference is always about 0.016s. Why? (this
>confused me a lot as i cant accurately measure time used for a function)

What drives the threads?
There might be a delay in the code that starts the theads, so it
starts a bunch, then sleeps for a bit. There are other process
running, so the main code can't keep starting threads without pauses.
As an experiment, you might bump up the starter's process priority.
See:  SetPriorityClass()  and  SetThreadPriority()

>Does it exist a more accurate way to log the time to milliseconds?

You might try GetSystemTime().
You could also look into QueryPerformanceCounter()

	LARGE_INTEGER    start, stop;
	QueryPerformanceCounter( &start );
	{do your thread stuff}
	QueryPerformanceCounter( &stop );
	{log  stop - start }
Technical Details
Message-ID: <jlao411g9ufg91ov065kqq9rhmumltrqmh@4ax.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <424bb15b@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,e46af9f8f318731f
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: Bob Gonder <notbg@notmindspring.invalid>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: get time problem
Date: Thu, 31 Mar 2005 09:08:31 -0800
Organization: MindSpring Enterprises, Inc.
Reply-To: notbg@notmindspring.invalid
Message-ID: <jlao411g9ufg91ov065kqq9rhmumltrqmh@4ax.com>
References: <424bb15b@newsgroups.borland.com>
X-Newsreader: Forte Agent 1.93/32.576 English (American)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 67.77.200.229
X-Trace: newsgroups.borland.com 1112288909 67.77.200.229 (31 Mar 2005 09:08:29 -0800)
Lines: 30
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail