Saturday, March 22, 2014

Time consumed function in Axapta

Performance measure in AX is a quite tough job and to achieve this job some built-in functions of AX can be used to determine the execution time of business logic.

TimeConsumed() a very useful function in Global class which we can be used to calculate the time taken to execute business logic in AX 2012. This function will return total time consumed in string format “X hours X minutes X seconds”. Note: It does not shows –negative value.
It handles up to a 24 hour time difference not dependent on start/end time. If time consumed > 24 hours will only report time over 24 hour intervals.

Demonstration

FromTime        fromTime;
ToTime          toTime;

fromTime    = timeNow();
toTime      = timeNow() + 50000;

//Timeconsumed()
info(strFmt('Time consumed %1', timeConsumed(fromTime, toTime)));