Can we set performance test case baseline programmatically in xcode?

1.3k views Asked by At

I have written some performance test cases using XCTest framework in my project. I was wondering is it possible to set baseline value for performance testing programmatically before the first run or is there any other way to set the baseline except from the performance result window.

2

There are 2 answers

0
CodenameDuchess On

I've unfortunately not found a way to set the baseline programmatically. But there are some other options for setting it.

After you have set the baseline once through Xcode you can then access the info.plist where the baseline is stored and update it that way.

To get to the stored baseline data right click on your .xcodeproj file and select "Show package contents" then go into the "xcshareddata" folder and the "xcbaselines" folder will have the data. I've verified that after updating the relevant info.plist the change is reflected in future test runs.

Alternatively, to avoid initially setting the baseline in Xcode you might try (as the article linked below suggests) to generate the baseline info.plist with a script, but I have not given that a try myself.

More info in this great article https://developer.squareup.com/blog/measureblock-how-does-performance-testing-work-in-ios/ in the "Where is the baseline stored?" and "Can I generate plists with a script?" sections.

Hope this info helps someone else out.

1
aledalgrande On

If you click on the gray diamond button next to your measure block, you will open a popup where you can register the latest performance result as baseline.