dart-sdk/pkg/front_end/tool/flame
Jens Johansen bb20bd0528 [CFE] More instrumentation options
This change:
* Fixes now-wrong asserts from when the origin of this was written
  years ago (the new async reality also allowed for simplification
  of the replacement code).
* Allows `*` as a wild-card name when processing candidates,
  so for instance `flow_analysis.dart|*` would mean everything in
  the file `flow_analysis.dart`.
* Allows taking the candidates via the command line without going
  through a file, so instead of having a file with
  `flow_analysis.dart|*` and passing that file with
  `--candidates=file` one say "--candidates-raw=flow_analysis.dart|*"
  - one can also give more either by giving it several times or by
  comma-separating it.
* Adds two new instrumentations: `--single-timer` and `--timer`
  where the first gives a single time for how long all instrumented
  stuff was on the stack, and the second one gives a timer for each
  instrumented procedure/constructor where it is on the stack.

One can for instance now instrument like this:

```
out/ReleaseX64/dart --enable-asserts pkg/front_end/tool/flame/instrumenter.dart -Diterations=10 pkg/front_end/tool/_fasta/compile.dart --single-timer "--candidates-raw=flow_analysis.dart|*"
```

or

```
out/ReleaseX64/dart --enable-asserts pkg/front_end/tool/flame/instrumenter.dart -Diterations=10 pkg/front_end/tool/_fasta/compile.dart --timer "--candidates-raw=flow_analysis.dart|*"
```

And it can be run via

```
out/ReleaseX64/dart pkg/front_end/tool/_fasta/compile.dart.dill.instrumented.dill pkg/front_end/tool/_fasta/compile.dart
```

And produce something like this (note that these examples are with -Diterations=10 so for 10 iterations):

For --single-timer:
```
Runtime: 3834491044
Runtime in seconds: 3.834491044
Visits: 52643690
Active: 0
Stopwatch frequency: 1000000000
```

For --timer:
```
[...]
flow_analysis.dart|_FlowAnalysisImpl.propertyGet: runtime: 818095151 (0.818095151 s), visits: 1328320, active: 0
flow_analysis.dart|FlowModel._updateVariableInfo: runtime: 827669322 (0.827669322 s), visits: 968180, active: 0
flow_analysis.dart|_FlowAnalysisImpl.variableRead: runtime: 1012755488 (1.012755488 s), visits: 1100140, active: 0
flow_analysis.dart|FlowModel.joinVariableInfo: runtime: 1118758076 (1.118758076 s), visits: 320810, active: 0
flow_analysis.dart|FlowModel.merge: runtime: 1185477853 (1.185477853 s), visits: 334100, active: 0
flow_analysis.dart|_FlowAnalysisImpl._merge: runtime: 1238735352 (1.238735352 s), visits: 334100, active: 0
```

Change-Id: Idaae6cdd2202b1a2d540da39db9aedb0c930329e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302280
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-05-09 15:13:58 +00:00
..
instrumenter.dart [CFE] More instrumentation options 2023-05-09 15:13:58 +00:00
instrumenter_lib.dart [CFE] Instrumenter can also count constructors; first run uses less ram because of trimming 2023-04-26 10:50:09 +00:00
instrumenter_lib_counter.dart [CFE] More instrumentation options 2023-05-09 15:13:58 +00:00
instrumenter_lib_single_timer.dart [CFE] More instrumentation options 2023-05-09 15:13:58 +00:00
instrumenter_lib_timer.dart [CFE] More instrumentation options 2023-05-09 15:13:58 +00:00