Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using Ticks to calculate number of seconds with two deci
Message
From
04/04/2006 17:29:21
Keith Payne
Technical Marketing Solutions
Florida, United States
 
 
To
04/04/2006 15:45:12
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01110385
Message ID:
01110436
Views:
11
>Is using Ticks the way to go to calculate the number of seconds with two decimals to obtain a processing time of an operation which normally executes within 0 to 2 seconds? I would like to obtain something like 0.32, 1.34, etc. Is the use of Date.Now.Ticks the approach to use?

Michel,

DateTimes have a 1-tick granularity, so they are good for timing stuff. The only thing that could negatively affect a simple DateTime based timer is that its thread may get interrupted between the last statement inside the timing block and the call to DateTime.Now.

If you really want a hardcore timer, you'd have to enclose the entire batch in a synclock.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform