Advertisement

07.18.2008 at 12:34AM PDT, ID: 23576030
[x]
Attachment Details

TDateTime::CurrentDateTime - problem with accurate time in milliseconds

Asked by Eimund in C++ Programming Language

Tags: Borland, C++ Builder, 2006

Hey,

I'm makeing a log where I need a timestamp for each log. The problem is the accuracy of the milliseconds when I request consecutive timestamps. In my log, when requesting a new timestamp within 100ms, it seems that TDateTime::CurrentDateTime jumps 10ms instead of 1ms. A piece of my selfmade log is shown below. As you se least significant millisecond digit is 3, and the change occures from the is the second least significant millisecond digit.

I call the function AddEvent (code snipp attached) from a multithreaded environment by using TThread::Synchronize.

Do any one know the cause of this? And if so, is there a way to get 1ms accuracy of the timestamp?

Regards
Eimund Smestad

18.07.2008 09:09:07.073      Data written to Interface 1
0X00 0X9C 0X34 0X3B 0X06 0X6C 0X9F 0XB1 0X7E 0XB7 0XBF 0X55 0XFA 0X40 0XC9 0XD9 0X56 0X96 0XC6 0X3C 0X34 0X3D 0XBA 0X9E 0X4F 0XF5

18.07.2008 09:09:07.083      IN-datalength on interface 1 is set to 26 bytes

18.07.2008 09:09:07.083      OUT-datalength on interface 1 is set to 32 bytes

18.07.2008 09:09:07.103      Data written to Interface 1
0X00 0X5E 0X56 0XB2 0XEE 0X89 0X95 0X05 0X2B 0X16 0X80 0X97 0X95 0X34 0X31 0X80 0X45 0X22 0XE2 0XAA 0X2D 0X81 0XB5 0X83 0X66 0X18 0XCA 0X92 0XA8 0XA6 0X80 0X88

18.07.2008 09:09:07.113      IN-datalength on interface 1 is set to 32 bytes


Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
void CUSB::Log::AddEvent(AnsiString event, bool blanckline)
{
	AnsiString text;
 
	tid = tid.CurrentTime();
	LongTimeFormat = "hh:nn:ss.zzz";
	text = "" + tid.CurrentDateTime() + "\t" + event;
	Log->Lines->Add(text);
	if(blanckline)
		Log->Lines->Add("");
}
 
Loading Advertisement...
 
[+][-]07.18.2008 at 11:40AM PDT, ID: 22038551

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.19.2008 at 12:17PM PDT, ID: 22043419

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: C++ Programming Language
Tags: Borland, C++ Builder, 2006
Sign Up Now!
Solution Provided By: itsmeandnobodyelse
Participating Experts: 2
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628