C
chivateatul
If DateTime.Now is called in a very large loop, it's a time consuming
& also CPU utilization increases.
Instead, getting current datetime by following way is much more
efficient.
So is there any performance issue with DateTime.Now? is this a correct
way to get current datetime?
Pseudo Code:
- - - - - - - - - - -
static DateTime dateTime = DateTime.Now;
static int StartTicks = Environment.TickCount;
public DateTime CurrentDateTime
{
get
{
return dateTime.AddMilliseconds(Environment.TickCount -
StartTicks);
}
}
& also CPU utilization increases.
Instead, getting current datetime by following way is much more
efficient.
So is there any performance issue with DateTime.Now? is this a correct
way to get current datetime?
Pseudo Code:
- - - - - - - - - - -
static DateTime dateTime = DateTime.Now;
static int StartTicks = Environment.TickCount;
public DateTime CurrentDateTime
{
get
{
return dateTime.AddMilliseconds(Environment.TickCount -
StartTicks);
}
}