timeConsumed()–a very useful function in Global class in AX 2012 [x++]

Posted by Sreenath Reddy on January 12, 2012

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 X hours X minutes X seconds. If X is 0 – will not include the value + text.
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.
Below is the example:
static void SGX_timeConsumed(Args _args)
    FromTime startTime = timeNow();
    int i;
    str dummyStr;
    for (i = 1 ; i <= 500000; i++)
        dummyStr += int2str(i);     
    info(strFmt("Total time consumed is  %1", timeConsumed(startTime, timeNow())));
time consumed 
Happy Dax6ng,
Sreenath Reddy G

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.