zijie0 / amparser Goto Github PK
View Code? Open in Web Editor NEWParse the Instruments Activity Monitor template trace result file to get CPU and memory usage
Parse the Instruments Activity Monitor template trace result file to get CPU and memory usage
When these lines are executed
XRActivityInstrumentRun *run = [NSUnarchiver unarchiveObjectWithData:traceData];
printf("\n%s\n", [[run description] UTF8String]);
program throws...
2018-03-14 19:41:14.862 AMParser[47185:635434] *** Terminating app due to uncaught exception 'NSArchiverArchiveInconsistency', reason: '*** Incorrect archive: unexpected byte'
*** First throw call stack:
(
0 CoreFoundation 0x00007fffd5c542cb __exceptionPreprocess + 171
1 libobjc.A.dylib 0x00007fffeaa6a48d objc_exception_throw + 48
2 CoreFoundation 0x00007fffd5cd2c3d +[NSException raise:format:] + 205
3 Foundation 0x00007fffd7638299 _decodeReusedCStringUsingTable + 329
4 Foundation 0x00007fffd7638131 -[NSUnarchiver decodeObject] + 73
5 AMParser 0x0000000107d224c6 -[PFTTrackSegment initWithCoder:] + 246
6 Foundation 0x00007fffd76385a6 _decodeObject_old + 416
7 Foundation 0x00007fffd7638fd5 _decodeValueOfObjCType + 978
8 Foundation 0x00007fffd7638bb7 -[NSUnarchiver decodeValueOfObjCType:at:] + 92
9 Foundation 0x00007fffd75d00b4 -[NSArray(NSArray) initWithCoder:] + 466
10 Foundation 0x00007fffd76385a6 _decodeObject_old + 416
11 AMParser 0x0000000107d2295c -[XRRun initWithCoder:] + 460
12 Foundation 0x00007fffd76385a6 _decodeObject_old + 416
13 Foundation 0x00007fffd76379e8 +[NSUnarchiver unarchiveObjectWithData:] + 64
14 AMParser 0x0000000107d2270c main + 236
15 libdyld.dylib 0x00007fffeb350235 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Abort trap: 6
# Xcode : 9.2
Refer attached 1.run file being used, I have modified directly to
NSString *resultUnzippedFile = @"~/Desktop/1.run";
NSURL *traceFile = [NSURL fileURLWithPath:[resultUnzippedFile stringByExpandingTildeInPath]];
NSData *traceData = [NSData dataWithContentsOfURL:traceFile];
// Deserialize the data and dump its content
XRActivityInstrumentRun *run = [NSUnarchiver unarchiveObjectWithData:traceData];
printf("\n%s\n", [[run description] UTF8String]);
Is the issue with Xcode version, instrument trace file being corrupted, since I have tried with multiple trace files.
为什么我解析出来的CPU usage (刚开始的几个sample)这么大?
Sample 0: Process: Usher CPU Usage: 0.00% Res Size: 12464.00 KiB Virt Size: 400908.00 KiB Timestamp: 2014/05/13 22:15:47:667
Sample 1: Process: Usher CPU Usage: 80.94% Res Size: 19276.00 KiB Virt Size: 419512.00 KiB Timestamp: 2014/05/13 22:15:48:714
Sample 2: Process: Usher CPU Usage: 74.09% Res Size: 38132.00 KiB Virt Size: 484316.00 KiB Timestamp: 2014/05/13 22:15:49:758
Sample 3: Process: Usher CPU Usage: 61.27% Res Size: 38756.00 KiB Virt Size: 484352.00 KiB Timestamp: 2014/05/13 22:15:50:798
Sample 4: Process: Usher CPU Usage: 21.99% Res Size: 38796.00 KiB Virt Size: 485308.00 KiB Timestamp: 2014/05/13 22:15:51:836
Sample 5: Process: Usher CPU Usage: 1.18% Res Size: 38796.00 KiB Virt Size: 485308.00 KiB Timestamp: 2014/05/13 22:15:52:875
Sample 6: Process: Usher CPU Usage: 1.19% Res Size: 38796.00 KiB Virt Size: 485308.00 KiB Timestamp: 2014/05/13 22:15:53:913
Sample 7: Process: Usher CPU Usage: 1.18% Res Size: 38800.00 KiB Virt Size: 485308.00 KiB Timestamp: 2014/05/13 22:15:54:950
Sample 8: Process: Usher CPU Usage: 1.21% Res Size: 38800.00 KiB Virt Size: 485308.00 KiB Timestamp: 2014/05/13 22:15:55:989
Sample 9: Process: Usher CPU Usage: 1.29% Res Size: 38804.00 KiB Virt Size: 485312.00 KiB Timestamp: 2014/05/13 22:15:57:027
Sample 10: Process: Usher CPU Usage: 1.18% Res Size: 38804.00 KiB Virt Size: 485312.00 KiB Timestamp: 2014/05/13 22:15:58:064
Sample 11: Process: Usher CPU Usage: 1.18% Res Size: 38780.00 KiB Virt Size: 484272.00 KiB Timestamp: 2014/05/13 22:15:59:102
Sample 12: Process: Usher CPU Usage: 1.32% Res Size: 38764.00 KiB Virt Size: 483752.00 KiB Timestamp: 2014/05/13 22:16:00:140
Sample 13: Process: Usher CPU Usage: 1.27% Res Size: 38032.00 KiB Virt Size: 482532.00 KiB Timestamp: 2014/05/13 22:16:01:177
Sample 14: Process: Usher CPU Usage: 1.21% Res Size: 38020.00 KiB Virt Size: 482520.00 KiB Timestamp: 2014/05/13 22:16:02:214
Sample 15: Process: Usher CPU Usage: 1.18% Res Size: 38024.00 KiB Virt Size: 482524.00 KiB Timestamp: 2014/05/13 22:16:03:250
Sample 16: Process: Usher CPU Usage: 1.40% Res Size: 38024.00 KiB Virt Size: 482524.00 KiB Timestamp: 2014/05/13 22:16:04:288
Sample 17: Process: Usher CPU Usage: 1.38% Res Size: 38024.00 KiB Virt Size: 482524.00 KiB Timestamp: 2014/05/13 22:16:05:330
Sample 18: Process: Usher CPU Usage: 1.15% Res Size: 38024.00 KiB Virt Size: 482524.00 KiB Timestamp: 2014/05/13 22:16:06:367
Sample 19: Process: Usher CPU Usage: 1.28% Res Size: 38024.00 KiB Virt Size: 482524.00 KiB Timestamp: 2014/05/13 22:16:07:404
Sample 20: Process: Usher CPU Usage: 1.16% Res Size: 38024.00 KiB Virt Size: 482524.00 KiB Timestamp: 2014/05/13 22:16:08:442
。。。。。。
这里的CPU Usage,Res Size, Virt Size指的是 一个进程的?还是所有进程的?如果是一个进程的,CPU怎么会到80%啊?是不是因为Appium server的影响,导致刚开始的CPU usage比较大?但是我用Instruments 打开这个trace 文件,Usher 的CPU usage 显示的是2%,这个是平均值?我只有34个sample,按这个log上的CPU usage,平均值也不止6%的。
Hi, I work on a large code base where there are many contributors to performance problems and it's not easy to tell just from things like the heaviest stack trace what's going on. Here are some things I'm interested in:
These sorts of in-depth things can't be analyzed using the existing instruments viewer. It would be amazing if you extended this current code base to support parsing CPU profiler traces. Just a thought :)
Launch Appium server by: node . -a 127.0.0.1 -k -U df5bb505a36e01948d847be7fa1c1c44d5c042d0 --tracetemplate /Users/.../alloc.tracetemplate
Then run script to automate iOS app in iPhone, instrumentscli4.trace file was generated.
unzip trace file:
Archive: instrumentscli4.trace/instrument_data/9253FE6B-26CA-4622-A5FD-760BE6801855/run_data/1.run.zip
inflating: Users/mxu/Documents/appium/instrumentscli4.trace/instrument_data/9253FE6B-26CA-4622-A5FD-760BE6801855/run_data/1.run
2014-05-13 16:14:18.143 AMParser[91630:507] * Terminating app due to uncaught exception 'NSArchiverArchiveInconsistency', reason: '* class error for 'XRObjectAllocRun': class not loaded'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff8b9ef41c __exceptionPreprocess + 172
1 libobjc.A.dylib 0x00007fff8acf5e75 objc_exception_throw + 43
2 CoreFoundation 0x00007fff8b9ef2cc +[NSException raise:format:] + 204
3 Foundation 0x00007fff897e66c0 _decodeClass + 564
4 Foundation 0x00007fff897e61b1 _decodeObject_old + 114
5 Foundation 0x00007fff8984b8e9 +[NSUnarchiver unarchiveObjectWithData:] + 67
6 AMParser 0x0000000106c01c54 main + 1172
7 libdyld.dylib 0x00007fff8ae995fd start + 1
8 ??? 0x0000000000000002 0x0 + 2
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Having a exception while "Deserializing the data and dump its content"
Exception line:
XRActivityInstrumentRun *run = [NSUnarchiver unarchiveObjectWithData:traceData];
Exception message:
2015-12-08 16:46:19.867 AMParser[2064:64238] *** Terminating app due to uncaught exception 'NSArchiverArchiveInconsistency', reason: '*** NSUnarchiver: inconsistency between written and read data for object 0x1006041b0' *** First throw call stack: ( 0 CoreFoundation 0x00007fff8dc2903c __exceptionPreprocess + 172 1 libobjc.A.dylib 0x00007fff8d75876e objc_exception_throw + 43 2 CoreFoundation 0x00007fff8dc28eed +[NSException raise:format:] + 205 3 Foundation 0x00007fff833f2499 _decodeObject_old + 680 4 Foundation 0x00007fff833f6fb6 +[NSUnarchiver unarchiveObjectWithData:] + 64 5 AMParser 0x00000001000022fb main + 1339 6 libdyld.dylib 0x00007fff8d2795c9 start + 1 7 ??? 0x0000000000000001 0x0 + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException (lldb)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.