🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: get time problem

#6887
From: Hans Galema
Date: Thu, 31 Mar 2005 08:47
60 lines
2561 bytes
Alex Liu wrote:

>         mylogfile->Write(FormatDateTime("hh:nn:ss.zzz", Now()), msg);

> Here is the strange part (well, I feel it strange). The log shows time like
> this:
> 14:37:01.984 thread_A start job
> 14:37:01.984 thread_A finish job
> 14:37:01.984 thread_B start job
> 14:37:01.984 thread_B finish job
> 14:37:01.984 thread_C start job
> 14:37:01.984 thread_C finish job

What I find strange is that the threads never mix. B comes
after A and when B finishes then comes C.

I would expect something like:
  14:37:01.984 thread_A start job
  14:37:01.984 thread_B start job
  14:37:01.984 thread_C start job
  14:37:01.984 thread_A finish job
  14:37:01.984 thread_C finish job
  14:37:01.984 thread_B finish job

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

> And i found that the time difference is always about 0.016s. Why? 

On my computer it is mostly 0.010

Did compare it with GetTickCount() and results are the same.

 >   mylogfile->Write(FormatDateTime("hh:nn:ss.zzz", Now()), msg);

Try:

   mylogfile->Write( FormatDateTime("hh:nn:ss.zzz", Now() )
	+ "  " + IntToStr ( GetTickCount() ));

I just did following test:

void __fastcall TForm1::Button1Click(TObject *Sender)
{
   TStringList *StringList = new TStringList;

   int times = 0;

   while ( ++times < 5000 )
    StringList->Add ( FormatDateTime("hh:nn:ss.zzz", Now() )
	 "  " + IntToStr ( GetTickCount() ));

   Memo1->Text = StringList->Text;

   delete StringList;
}

So your threads are logging to fast!

Hans.
Technical Details
Message-ID: <424bb9ab@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news2.google.com!news.maxwell.syr.edu!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
Date: Thu, 31 Mar 2005 10:47:37 +0200
From: Hans Galema <notused@notused.nl>
User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206)
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: get time problem
References: <424bb15b@newsgroups.borland.com>
In-Reply-To: <424bb15b@newsgroups.borland.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 129.125.201.248
Message-ID: <424bb9ab@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1112258987 129.125.201.248 (31 Mar 2005 00:49:47 -0800)
Lines: 60
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail