Timing a X++ operation in milliseconds

1 10 2009

I’m in the process of optimising some functions in Dynamics AX and need to be able to compare the processing times between the old function and my new function to see if I’m actually making any improvements on my code.  However I struggled to find a nice function to retrieve milliseconds out of the system, as seconds are just too big a unit. Eventually I located a WinAPI function call that suits my needs nicely called WinAPI::getTickCount(); it returns “the number of milliseconds that have elapsed since the system was started, up to 49.7 days”  (MS Documentation) So in code:

TimeInMS        startTime,endTime;
startTime = WinAPI::getTickCount();
endTime = WinAPI::getTickCount();
info(strfmt(‘%1 Milliseconds’,endTime-startTime));




Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: