Calculate Time Consumption in AX 2012
Hi All,
There is a very useful function timeConsumed() in Global class which we can use to calculate the time taken to execute business logic in AX 2012.
This function will return time consumed string in the form of XX hours XX minutes XX seconds (00:00:00). It handles up to a 24 hour time difference not dependent on start/end time.
Limitation: If time consumed is greater then 24 hours will only report time over 24 hour intervals.
Limitation: If time consumed is greater then 24 hours will only report time over 24 hour intervals.
Code:
static void DemoTimeConsumed(Args _args)
{
FromTime startTime = timeNow();
int i;
str res;
;
for (i = 1 ; i <= 2650000; i++)
{
res+= int2str(i);
}
info(strFmt("Total time consumed with this operation is %1", timeConsumed(startTime, timeNow())));
}
Enjoy DAX!!!
No comments:
Post a Comment