@@ -174,72 +174,53 @@ If profiling a Release build, you'll need to edit your
174
174
175
175
Debug builds already set this value by default.
176
176
177
+ In order to save method JIT statistics, the application has to be built
178
+ with the `$(_AndroidMethodsStats)` MSBuild property set to `true`.
179
+
177
180
Next, run the `adb` command:
178
181
179
182
> adb shell setprop debug.mono.log timing,default
180
183
181
- After launching the app, you can find a file that was recorded during
182
- startup:
184
+ After launching the app, wait for the desired period of time and then send
185
+ an Android intent to the application in order to actually save data into
186
+ the `methods.xml` file:
187
+
188
+ > adb shell am broadcast -a mono.android.app.DUMP_TIMING_DATA com.xamarin.android.helloworld
189
+
190
+ After this is done, you can find a file that was recorded during startup:
183
191
184
192
> adb shell run-as com.xamarin.android.helloworld ls files/.__override__
185
- counters.txt
186
- methods.txt
193
+ methods.xml
187
194
188
- Make sure to use your app's package name instead of
189
- `com.xamarin.android.helloworld`.
195
+ Make sure to use your app's package name instead of `com.xamarin.android.helloworld`.
190
196
191
197
You can pull these files to your machine by doing:
192
198
193
- > adb shell run-as com.xamarin.android.helloworld cat files/.__override__/counters.txt > counters.txt
194
- > adb shell run-as com.xamarin.android.helloworld cat files/.__override__/methods.txt > methods.txt
199
+ > adb shell run-as com.xamarin.android.helloworld cat files/.__override__/methods.xml > methods.xml
195
200
196
201
If you ever need to reset/clear these directories, you can
197
202
uninstall/reinstall the app or merely:
198
203
199
- > adb shell run-as com.xamarin.android.helloworld rm -r files/.__override__/
200
-
201
- `counters.txt` has some interesting summary information provided by
202
- Mono:
203
-
204
- ## Runtime.register: type=HelloWorld.MainActivity, HelloWorld
205
- JIT statistics
206
- Discarded method code : 1
207
- Time spent JITting discarded code : 0.82 ms
208
- Try holes memory size : 896
209
- Dynamic code allocs : 3
210
- Dynamic code bytes : 584
211
- Dynamic code frees : 0
212
- Unwind info size : 5985
213
- Calls to trampolines : 1994
214
- JIT trampolines : 952
215
- Unbox trampolines : 2
216
- Static rgctx trampolines : 7
217
- Async JIT info size : 0
218
- Max native code in a domain : 0
219
- Max code space allocated in a domain: 0
220
- Total code space allocated : 0
221
- Hazardous pointers : 0
222
- Compiled methods : 921
223
- Methods from AOT : 0
224
- Methods JITted using mono JIT : 921
225
- Methods JITted using LLVM : 0
226
- Methods using the interpreter : 0
227
-
228
- _NOTE: that `counters.txt` is not available in .NET 6 projects._
229
-
230
- `methods.txt` has the individual JIT times of each method:
231
-
232
- JIT method begin: System.OutOfMemoryException:.ctor (string) elapsed: 0s:20::136721
233
- JIT method done: System.OutOfMemoryException:.ctor (string) elapsed: 0s:20::605627
204
+ > adb shell run-as com.xamarin.android.helloworld rm files/.__override__/methods.xml
205
+
206
+ `methods.xml` has the individual JIT times of each method:
207
+
208
+ <method name =" Java.Lang.Object:GetObject (intptr,Android.Runtime.JniHandleOwnership,System.Type)" invocation_count =" 1" jit_time =" 0:0::20915" jit_status =" success" />
209
+
210
+ If methods statistics were gathered in `Release` mode, the `invocation_count` attribute of most entries
211
+ will be `0`. This is due to the fact that the Mono runtime allows us to gather call statistics only
212
+ when running with the interpreter instead of JIT. In order to properly count calls to each method, the
213
+ application needs to be built with the `$(UseInterpreter)` MSBuild property set to `true` (it works both in
214
+ `Debug` and `Release` modes).
234
215
235
216
This is not particularly readable, so you can use our
236
217
[jit-times][jit_times] command-line tool to get better/sorted output:
237
218
238
219
# Windows / .NET
239
- jit-times.exe methods.txt > methods-sorted.txt
220
+ jit-times.exe methods.xml > methods-sorted.txt
240
221
241
222
# Mac / Mono
242
- mono jit-times.exe methods.txt > methods-sorted.txt
223
+ mono jit-times.exe methods.xml > methods-sorted.txt
243
224
244
225
Which outputs:
245
226
@@ -441,7 +422,7 @@ target:
441
422
Project Evaluation Performance Summary:
442
423
12 ms samples\HelloWorld\HelloLibrary\HelloLibrary.csproj 1 calls
443
424
98 ms samples\HelloWorld\HelloWorld.csproj 1 calls
444
-
425
+
445
426
Target Performance Summary:
446
427
275 ms _UpdateAndroidResgen 2 calls
447
428
354 ms _GenerateJavaStubs 1 calls
@@ -450,7 +431,7 @@ target:
450
431
865 ms _ResolveSdks 2 calls
451
432
953 ms ResolveProjectReferences 2 calls
452
433
1219 ms _CompileToDalvikWithD8 1 calls
453
-
434
+
454
435
Task Performance Summary:
455
436
681 ms Csc 2 calls
456
437
809 ms ValidateJavaVersion 2 calls
0 commit comments