Collecting Performance Data While Running Unit Tests
A few years ago, I was teaching the basics of our %UnitTest framework during Caché Foundations class (now called Developing Using InterSystems Objects and SQL). A student asked if it was possible to collect performance statistics while running unit tests. A few weeks later, I added some additional code to the %UnitTest examples to answer this question. I’m finally sharing it on the Community.
The %SYSTEM,Process class provides several metrics that you can collect for a process (other than Duration).
- Duration
- Lines Executed
- Global References
- System CPU Time
- User CPU Time
- Disk Read Time
set msg = "Performance: " _
Comments
To get more reliable figures on performance, we usually take the following approach (# 1):
set nTop=1000000 // number of test repetitions
for each test_j {
init_counters
for i=1:1:nTop {
run_test_j
}
save_counters_for_test_j(nTop)
}because it introduces less extra payload and provides more precise measuring than alternative approach (#2):
set nTop=1000000
for i=1:1:nTop {
for each test_j {
init_counters
run_test_j
save_counters_for_test_j
}
}
for each test_j {
aggregate_counters_for_test_j(nTop)
}
The article is considered as InterSystems Data Platform Best Practice.