Information générale
Catégorie:
Code, syntaxe and commandes
>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.
Précédent
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement