Capturing Performance Data for Native iOS Apps
As mobile app testing becomes more and more ubiquitous, the lines between different kinds of machine-controlled testing can become blurred. For example, performance testing is go an integral part of the ontogeny cycle. And for full reason -- -users of mobile apps have very low tolerance for poorly performing apps. We & # x27; ve already exhibit how it & # x27; s possible to, and we can do something very alike for iOS. Performance essay for iOS apps involves theInstrumentsusefulness distributed by Apple alongside Xcode. Instruments comes with a number of built-in analyses and measurements. If you open it up, you & # x27; re greeted with a list of these: Essentially, these are the various execution measurements it will be possible to initiate expend Appium, so keep an eye on this listing for ideas about what you might want to measure for your app, and make sure to check out Apple & # x27; s docs if you want to cognise more about what each of these do. For our purposes in this newssheet, we & # x27; re travel to choose the & quot; Time Profiler & quot; instrument. But since we & # x27; re using Appium, we don & # x27; t need to tick on anything in the Instruments app itself. Instead, we & # x27; ll head to our codification editor! The way iOS profiling works with Appium is with two commands: one to start the profiling and one to stop it and dump the data out to us for viewing. These dictation are useable as of Appium 1.8, via themobile:command interface. Essentially, it & # x27; s as simple as: Pro tip: Tools like SUSA can handle this autonomously — upload your app and get results without writing a single test script. We use themobile: startPerfRecord and mobile: stopPerfRecordcommands to signal to Appium when during our script we & # x27; d like the profiling to occur. There is one wrinkle, yet: for any of this to act, we necessitate to have depart the Appium server with the-- relaxed-securityflag. This is because Instruments can gather data from the scheme as a whole, not just the AUT. (It & # x27; s so a security endangerment to expose potentially sensitive system information to Appium sessions running from a distant client, for instance in the circumstance of a cloud Appium host). There & # x27; s besides another facet of the snip above that I haven & # x27; t yet touched on: what about theargs parameter to these methods? The & quot; start & quot; method conduct an argument object with three fields, for example: Here we have: For stopPerfRecord, the alone disceptation we care about isprofileName, which should feature the same value as what we passed in tostartPerfRecord, so Appium know which of potentially multiple traces to stop. The other wrinkle here is the return value ofstopPerfRecord; what & # x27; sb64Zip theorise to imply? Well, what Appium is afford back to you when you kibosh performance recording is actually anInstruments Trace Document, which happens to be a directory under the toughie. Since directory are impossible to direct in draw format, Appium zips up this .tracedirectory and hand it backwards to the client script in base64 encryption. To make use of this data, we have to decrypt it and underprice it into a zipfile on our system, with codification like the chase: At this point, we & # x27; ll have a decent littletrace.zipsitting at the specified emplacement on disc. We can now simply unzip it and double-click it to open the trace file up in the Instruments viewer: In this Instruments UI, we can dig through the diverse threads that were active during the profiled portion of our Appium test, and see which routines that thread spent most of its clip in (via the stacktrace snapshots guide by the profiler). This can help us to find CPU-hungry areas of our app, which we might settle to offload to a worker thread to, for instance. There are all variety of condition, and likely avenues of improvement based on the data gleaned from these trace file, but that is outside the scope of this brief tutorial. What & # x27; s important today is that you & # x27; ve figured out how to becharm the data! Since a common use case might be to profile your app over time, you might consider attaching the zipped suggestion files to your test report in your CI system, so that if a exam fails, you also receive some juicy profile datum that could help in remediating the test. (There & # x27; s really an easy way to post the zip file straight to an asset manager that endorse HTTP uploads; check out theAppium XCUITest performance docsfor more info). For the interest of showing a full model, the following is a simple examination which lifts the literal app behavior from a different edition of Appium Pro, and simply runs those step a number of times while bracketed by execution recording. The zip file is then written to disk, merely as above, where I can jubilantly open up the story in Instruments. Lead, Content Marketing, HeadSpin Inc. Piali is a dynamical and results-driven Content Marketing Specialist with 8+ years of experience in crafting engaging narratives and marketing collateral across diverse industries. She excels in collaborating with cross-functional teams to acquire innovative content strategies and deliver compelling, reliable, and impactful content that resonates with target audiences and enhances brand authenticity. Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts needed. Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts..png)



Capturing Performance Data for Native iOS Apps
AI-Powered Key Takeaways

Optimize digital experience with the mobile app performance testing capableness of the HeadSpin.!
driver.executeScript (`` mobile: startPerfRecord '', args); // here: do some stuff in the app that you want to profile String b64Zip = (String) driver.executeScript (`` mobile: stopPerfRecord '', args); // hither: convert the base64-encoded zip file to existent file data on your schemeCheck out:
HashMapAlso check:
File traceZip = new File (`` /path/to/trace.zip ''); String b64Zip = (String) driver.executeScript (`` mobile: stopPerfRecord '', args); byte [] bytesZip = Base64.getMimeDecoder () .decode (b64Zip); FileOutputStream current = new FileOutputStream (traceZip); stream.write (bytesZip);
import io.appium.java_client.MobileBy; import io.appium.java_client.ios.IOSDriver; import java.io.File; meaning java.io.FileOutputStream; import java.net.URL; signification java.util.Base64; significance java.util.HashMap; import org.junit.Assert; significance org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.remote.DesiredCapabilities; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; public stratum Edition012_iOS_Performance {private String APP = `` https: //github.com/cloudgrey-io/the-app/releases/download/v1.3.0/TheApp-v1.3.0.app.zip ''; private File traceZip; private By msgInput = By.xpath (`` //XCUIElementTypeTextField [@ name=\ '' messageInput\ ''] ''); individual By savedMsg = MobileBy.AccessibilityId (`` savedMessage ''); private By saveMsgBtn = MobileBy.AccessibilityId (`` messageSaveBtn ''); private By echoBox = MobileBy.AccessibilityId (`` Echo Box ''); private String TEST_MESSAGE = `` Hello World ''; @ Test public void testAppActivity () throws Exception {// Note: Appium server must have be started with -- relaxed-security DesiredCapabilities capabilities = new DesiredCapabilities (); capabilities.setCapability (`` platformName '', `` iOS ''); capabilities.setCapability (`` platformVersion '', `` 11.3 ''); capabilities.setCapability (`` deviceName '', `` iPhone X ''); capabilities.setCapability (`` app '', APP); IOSDriver driver = new IOSDriver < > (new URL (`` http: //localhost:4723/wd/hub ''), capabilities); traceZip = new File (`` /path/to/trace.zip ''); try {HashMapPiali Mazumdar
Capturing Performance Data for Native iOS Apps
4 Parts
-1280X720-Final-2.jpg)
Regression Intelligence practical guide for advanced users (Part 3)
-1280X720-Final-2.jpg)
Regression Intelligence practical guide for advanced users (Part 4)
Discover how HeadSpin can empower your business with superior testing capabilities







Discover how HeadSpin can empower your concern with superior testing capabilities
Discover how HeadSpin can empower your business with superior testing capabilities
Connet Now


Automate This With SUSA
Test Your App Autonomously







.png)












