Microsoft Dynamics AX : Stopwatch tip
You are here: >Microsoft Dynamics AX : Stopwatch tip
Welcome to our eBECS technical blog. A blog to spread the knowledge based on real life projects and hands-on experience from our technical gurus.
In this post I will talk about a simple yet powerful tool used in performance measurements.
The stopwatch: is a utility class built on .NET core types to measure the duration between start and stop methods
It can be used in different scenarios such as:
1- Troubleshooting and performance measurements
2- User output
3- Logging
Here is an example of the first scenario
Performance measurement:
Let’s say you have a performance issue and want to measure before and after effect, by comparing the time consumed.
In this example a job was created to update customer accounts using a regular update (While select update)
static void EBCStopwatch_Example1_Before(Args _args) { CustTable custTable; Counter counter = 0; EBCStopwatch stopwatch = new EBCStopwatch();
stopwatch.start();
ttsBegin; while select forupdate AccountNum from custTable { custTable.AccountNum = “OLD_” + custTable.AccountNum; custTable.update(); counter++; } ttsCommit;
stopwatch.stop(strFmt(“%1 customers updated”, counter), EBCTimePart::Millisecond); } |
A better approach was found to use UPDATE_RECORDSET which hits the database once.
static void EBCStopwatch_Example1_After(Args _args) { CustTable custTable; EBCStopwatch stopwatch = new EBCStopwatch();
stopwatch.start();
custTable.skipDataMethods(true); update_recordSet custTable setting AccountNum = “OLD_” + custTable.AccountNum;
stopwatch.stop(strFmt(“%1 customers updated”, custTable.RowCount()), EBCTimePart::Millisecond); } |
A comparison is shown below, which shows that the old code is 6 times slower than the new code:
|
Before |
After |
Duration |
2679 ms (3 seconds) |
517 ms (0.5 second) |
You can use the stop() method to show the time in Hours, Minutes, Seconds or Milliseconds. Also it returns the duration to be stored in a variable for later use.
The XPO is included in this post for the class and examples.
Merry Christmas and happy coding till the next post…
Looking for a Microsoft Dynamics Partner then contact ebecs.
- About Us
- Partners
- Careers
- Contact us
- eBECS and the Microsoft Core Data Platform
- Microsoft Dynamics NAV in Property Management
- Microsoft Dynamics Nav Manufacturing Solutions
- Microsoft Dynamics NAV Cloud pricing
- Drive your Azure Momentum with SQL Managed Instance
- Compare Microsoft Dynamics AX VS NAV
- Microsoft Azure Data Centre Migration Guide
- Microsoft Dynamics 365 Business Central or 365 for Finance & Operations?
- Introduction to Microsoft Dynamics 365 for Finance and Operations
- Microsoft Dynamics 365 Business Central or 365 for Finance & Operations? Thank You
- Microsoft Dynamics 365 Business Central or Dynamics 365 Finance
- Compare Microsoft ERP Solutions
- Compare Microsoft ERP Solutions, Dynamics NAV vs Dynamics 365 Business Central
- Microsoft Dynamics 365 Business Central Price
- Compare Microsoft ERP
Categories
- Adoption & Change Management (1)
- AI (3)
- Asset Management (1)
- Automation (1)
- Azure (2)
- Business Automation (1)
- Business Insights (1)
- Call Centre (1)
- Call Scripting (1)
- Canvas Apps (1)
- Click Dimensions (1)
- Common Data Service (2)
- Connected Banking (1)
- Contact Centre (1)
- Crisis Communication (1)
- CRM (3)
- Customer Data Platform (1)
- Customer Insights (1)
- Data Analytics/BI (30)
- Data Management (1)
- Data Warehouse (1)
- Digital Banking (1)
- DXC Connected-Banking-as-a-Service (1)
- DXC Intelligent Survey (1)
- Dynamics 365 (38)
- Dynamics 365 Finance (2)
- Dynamics 365 Sales Insights (1)
- Dynamics 365 Supply Chain Management (1)
- Dynamics AX (51)
- Dynamics CRM (23)
- Dynamics Field Service (11)
- Dynamics NAV (11)
- Dynamics Project Service Automation (PSA) (15)
- eBECS (4)
- eBECS Marketing (1)
- eBECS Policies (1)
- ERP (2)
- Frontline Workers (1)
- Internet of Things (IoT) (16)
- Master Planning AX (4)
- Microsoft 365 (1)
- Microsoft Lifecycle Services (4)
- Power Apps (6)
- Power Automate (6)
- Power BI (3)
- Power Platform (9)
- Power VIrtual Agent (1)
- PowerApps (3)
- Project Service Automation (2)
- Quality Management (1)
- Remote working (1)
- Retail Banking (1)
- Robotic Process Automation (1)
- RPA (1)
- Sales (1)
- Surface Hub (3)
- Top Tips (2)
News
Upcoming Events - Register Now
Join our list
eBECS will invite you to webinars, events and keep you up to date with relevant news. You can unsubscribe at any time.