Post not yet marked as solved
I wrote a few unit test cases using XCTest by mocking the data? Is there any best practice to have multiple test profiles with different data sets? Sometime mock should return nil, sometimes an array with 2 elements and sometimes an array with 10 elements. How to have multiple test profiles?
Post not yet marked as solved
Is it possible to write symbols for JIT functions in a way that Instruments will pick them up? I tried sending DWARF info to GDB's __jit_debug_register_code which worked in LLDB, but not Instruments's CPU trace. I also tried generating a perf-PID.map file but it appears Instruments doesn't support that either. Is this possible at all in Instruments?
Post not yet marked as solved
We are looking for a complete solution of do performance tracing. One key point is to be able to run the perf trace in production environment.
We have been using os_signpost in our app. We know how to use xctrace to record a perf report in our dev environment.
We need a way run the perf trace on customer end. However, asking a customer to install a 10GB+ xcode is not practical.
My 2 questions are:
Is there a standalone version of Instruments or a command line tool that is small enough to download and run on customer mac to do the os_signpost tracing?
If there is no such tool, is it possible to use some sort of APIs to create a such tool myself?
Regards
Liam
Post not yet marked as solved
It seems like signposts generated with os_signpost() APIs are not appearing in the trace files collected with ktrace (ktrace artrace).
On the other hand, if the signposts are generated with kdebug_signpost APIs - they do show up correctly.
Is this expected behavior?
Specially since the kdebug_signpost APIs are now deprecated?
Thanks.
Devendra.
ps: The os_signpost generated signposts do appear if capturing with Instruments app, just that they are not captured by ktrace.
Post not yet marked as solved
I'm using macOS BigSur, Instruments 12.4.
Every time I try to capture a System Trace (no matter how short) it leads to the entire system eventually getting stuck.
First of all Instruments starts analyzing data, and at some point stops moving further.
If I try to kill Instruments - it goes away from the Force Quit Applications list, but still stays on screen.
At this point, I'm not able to close any other applications or even shut down the system - everything starts getting stuck.
The only way to recover is to do a hard power reset.
This is on a MacBook Pro.
Is there a solution for this?
Post not yet marked as solved
I have this performance test to check Memory usage during scrolling.
func testMemotyUsage() {
let app = XCUIApplication()
let measureOptions = XCTMeasureOptions()
measureOptions.invocationOptions = [.manuallyStop]
measure(
metrics: [XCTMemoryMetric(application: app)],
options: measureOptions
) {
app.buttons["Listing Page"].tap()
swipeUp()
stopMeasuring()
tapBack()
}
}
func tapBack() {
app.navigationBars.buttons.element(boundBy: 0).tap()
}
func swipeUp() {
collectionView.swipeUp(velocity: .fast)
}
func swipeDown() {
collectionView.swipeDown(velocity: .fast)
}
var collectionView: XCUIElement {
app.collectionViews["collectionViewId"]
}
But when I run the test, it doesn't display any metrics at all.
I tried to update
XCTMemoryMetric(application: app) -> to XCTMemoryMetric()
In this case it at least shows some result, but the result is incorrect, because as it's seen on the screenshot below, the app consumes around 130 MB of memory, but the test shows 9 KB only. BTW the real memory consumption is around 130-150 MB, because there are a lot of images in the collection view.
My guess that it doesn't show the correct result, because the app is not passed as a parameter. Although when I pass the app, it doesn't show any results at all 🙃
Same issue happens when I write the test to check CPU usage with XCTCPUMetric.
Questions:
How to write a performance test that will show memory and CPU usage of some UI tests?
(Optional) Why when I run the test in Debug mode, it shows that 2 processes are running (ExampleUITests - the target for UI tests, and Example - the main target). Is it normal and when I measure the memory consumption, am I supposed to get the consumption of the main target Example, right?
Post not yet marked as solved
I updated my xcode 12.5 to xocde 13 and after that Install command line developer tool popup come & ask to install "Instruments". I click on install & accepted license. and installation finished.
But I am getting this popup again & again even i cancelled it still it is showing again & again.
Please help me here to get rid from this popup.
On three different machines (all running Xcode 13 and Big Sur), it always tells me that the command-line developer tools need to be installed. I've "installed" them four times so far on one machine, and at least twice on the other two.
Post not yet marked as solved
On three different machines (all running Xcode 13 and Big Sur), it always tells me that the command-line developer tools need to be installed. I've "installed" them four times so far on one machine, and at least twice on the other two.
Post not yet marked as solved
I'd like to confirm the battery usage of an app I am developing on iOS, specifically on Xcode 13 and iOS 15. (Note: This app previously showed no issues with battery usage on previous versions of iOS.)
Previously, it seems that there were two ways to gather energy usage information:
#1. On the device under Settings > Developer > Logging
As per Apple's documentation described in the section titled "Log Energy Usage Directly on an iOS Device".
However, on iOS15, I can't find any options for logging under Developer or anywhere under settings even when searching.
#2. Profiling via Instruments using the "Energy Log" template
As per the same documentation from Apple described in the section "Use the Energy Diagnostics Profiling Template".
While it is still available in Xcode 12, this template is missing in Xcode 13. Naturally, it's also not possible to profile an iOS15 device with Xcode 12.
Digging through the Xcode 13 release notes, I found the following:
Instruments no longer includes the Energy template; use metrics reporting in the Xcode Organizer instead. (74161279)
When I access the Organizer in Xcode (12 or 13), select an app and click "Energy" for all versions of the app, it shows the following:
Apple's documentation for "Analyzing the Performance of Your Shipping App" says:
"In some cases the pane shows “Insufficient usage data available,” because there may not be enough anonymized data reported by participating user devices. When this happens, try checking back in a few days."
Well over a year into production and having sufficient install numbers, I have a feeling that waiting a few days might not do much.
I would like to determine if this is a bug in my app or a bug in iOS15. How can energy usage data be gathered using Xcode 13 on iOS 15?
Post not yet marked as solved
One of our team members reported very high memory usage for our Network System Extension in Activity Monitor. Therefore, to check for leaks and accumulating memory, I plugged it into Instruments which shows quite low usage (~4MB) compared to Activity Monitor (40MB) at same moment. I am instrumenting release version of my extension (and App). So, my questions are:
Why such a huge difference in these two tools?
Which one should be considered more authentic/valid memory usage
Is there any upper limit for Network System Extension? From my iOS experience, I remember iOS has 15MB limit for Network Extensions. Is there any such limit for Network System Extensions?
Post not yet marked as solved
As per Xcode 13 Release Notes -
To support the new JSON-format crash logs generated in macOS Monterey and iOS 15, Instruments includes a new CrashSymbolicator.py script. This Python 3 script replaces the symbolicatecrash utility for JSON-format logs and supports inlined frames with its default options. For more information, see: CrashSymbolicator.py --help. CrashSymbolicator.py is located in the Contents/SharedFrameworks/CoreSymbolicationDT.framework/Resources/ subdirectory within Xcode 13. (78891800)
usage: CrashSymbolicator.py [-h] [-d dSYM] [-s SEARCH_PATH] [-o OUTPUT_FILE] [-p] [-w N] [--no-inlines] [--no-source-info] [--only-missing] [--no-system-frameworks]
[--no-demangle] [-v]
LOGFILE
Symbolicate a crash log
python3 CrashSymbolicator.py -d PATH_TO_DSYMS -o PATH_TO_OUTPUT CRASH_LOG_FILE
When we run this command getting the following errors
Traceback (most recent call last):
File "CrashSymbolicator.py", line 502, in
symbolicate(args)
File "CrashSymbolicator.py", line 482, in symbolicate
crash_log.write_to(args.output, args.pretty)
File "/Applications/Xcode.app/Contents/SharedFrameworks/CoreSymbolicationDT.framework/Versions/A/Resources/JSONCrashLog/JSONCrashLog.py", line 167, in write_to
ips_header_dictionary = vars(self.ips_header)
TypeError: vars() argument must have dict attribute
Post not yet marked as solved
I wrote simple NSMutableData test project.
I profiled with allocations instruments. It shows alloc1() total bytes are 55MB.
But alloc1() only called once and alloced byte should be 1MB. I cannot find the reason of 55MB allocation in alloc1()
Replace this code with fresh macOS App project on Xcode13.
#import "ViewController.h"
@implementation ViewController {
NSTimer *mTimer;
NSMutableData *mData1;
NSMutableData *mData2;
}
- (void)viewDidLoad {
[super viewDidLoad];
mData1 = nil;
mData2 = nil;
mTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self
selector:@selector(timer_cb) userInfo:nil repeats:YES];
}
- (void) timer_cb {
if (mData1 == nil) {
[self alloc1];
}
if (mData2 == nil) {
[self alloc2];
}
[self copy1];
}
- (void) alloc1 {
NSLog(@"alloc1");
mData1 = [NSMutableData dataWithCapacity:1024*1024];
}
- (void) alloc2 {
NSLog(@"alloc2");
mData2 = [NSMutableData dataWithCapacity:1024*1024];
[mData2 resetBytesInRange:NSMakeRange(0, 1024*1024)];
}
- (void) copy1 {
[mData1 replaceBytesInRange:NSMakeRange(0, 1024*1024) withBytes:mData2.bytes];
}
@end
Post not yet marked as solved
Hii,
im having troubles updating the software of my ipad 6thgen the reason is, there are no software Update button on my Ipad settings/general, and if i try to update it using our computer and itunes it is also not working..can you please make a solution for this thank you😊🥺
Post not yet marked as solved
Use instrument to test the frame rate of iPhone 13 Pro App, Core Animation FPS only displays 60 at most, not 120。please tell me why. vsync displays 8ms, but the frame rate does not display 120,why???
Post not yet marked as solved
Hello,
I'm attempting to automate some performance tests we currently do manually using signposts and Instruments.
It looks like XCTOSSignpostMetric is the perfect tool for the job, but I can't get it to play nicely. If I use the pre-defined signpost metric constants (customNavigationTransitionMetric, scrollDecelerationMetric, etc), it works fine. If I use a custom signpost using the
XCTOSSignpostMetric.init(subsystem: category: name:)
initializer, nothing happens.
The documentation is very sparse on this topic and Googling, Binging, Githubing and Twittering have come up empty.
I reduced the issue to the smallest example I could ( https://github.com/tspike/SignpostTest ).
What am I doing wrong?
Thanks,
Tres
Environment details:
macOS 11.6
Xcode 12.5.1
iOS 14.6
iPhone SE 1st Gen
In the app:
...
let signpostLog = OSLog(subsystem: "com.tspike.signpost", category: "signpost")
let signpostName: StaticString = "SignpostTest"
@main
struct SignpostTestApp: App {
init() {
os_signpost(.begin, log: signpostLog, name: signpostName)
DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(500), execute: {
os_signpost(.end, log: signpostLog, name: signpostName)
})
}
...
}
In the test
func testSignposts() throws {
let app = XCUIApplication()
// No performance data
let metric = XCTOSSignpostMetric.init(subsystem: "com.tspike.signpost",
category: "signpost",
name: "SignpostTest")
// Works as expected
// let metric = XCTOSSignpostMetric.applicationLaunch
let options = XCTMeasureOptions()
options.iterationCount = 1
measure(metrics: [metric], options: options, block: {
app.launch()
})
}
Post not yet marked as solved
Hi, we're profiling our iOS app with XCode13. We found there are cache miss counters like L1D_CACHE_MISS_LD and L1D_CACHE_MISS_ST. However, we couldn't find a counter related to L1 data cache access. Therefore, we couldn't calculate the cache miss rate.
But we found there is a L1D_TLB_ACCESS counter. Can we assume that every TLB access will lead to a data cache access, so we can use L1D_TLB_ACCESS as L1 data cache access?
Post not yet marked as solved
Instruments CoreAnimation FPS don't display 120,why???
Post not yet marked as solved
When measuring "Game Performance" from Instruments in "Deferred" mode with a connected device, I'm seeing huge regions of data go missing. I'm trying to figure out why this might be the case, and what I can do to capture more reliable data.
Ideally I would like to capture 60 seconds of gameplay and analyze the performance, but very often only a fraction of the graph has data. The amount varies wildly, even on a very basic tutorial-level Metal application. Sometimes I'll get the full 60 seconds, other times only 5 seconds (with 55 seconds of empty space), and I'm always running with the same settings.
Any ideas? Is anyone else able to reliably get the full set of data?
**For reference, I'll state that I'm using an iPhone 13 Pro and an iPad Pro 11, so I don't think the devices are too underpowered. I even tested on two different computers and got similar results.
Post not yet marked as solved
I'm using xcrun xctrace export --output results.xml --input test_trace.trace --xpath '//trace-toc[1]/run[1]/data[1]/table' to export data from a test run with instruments as part of my app's CI. With Xcode 12 this resulted in an xml file that I could parse relatively quickly, but now with Xcode 13 the export process itself is taking 90+ seconds and generating a 160mb xml file for a 10 second recording.
I noticed the table that has increased is the time-sample schema. Just attempting to export this table with --xpath '//trace-toc[1]/run[1]/data[1]/table[4]' takes quite a while. The table has about 790 thousand rows. I'm using a custom instrument based off the time profiler, and still have about the same number of stack trace samples in my output. Did anything change in Xcode 13 that caused instruments to include many more time samples that aren't corresponding to a stack trace? Is it possible to disable this to have fewer time samples in my trace (while preserving the stack trace frequency) so the xml can be parsed quicker?