OLD | NEW |
1 # mojo_benchmark | 1 # mojo_benchmark |
2 | 2 |
3 `mojo_benchmark` allows you to run performance tests for any Mojo application | 3 `mojo_benchmark` allows you to run performance tests for any Mojo application |
4 that participates in the [tracing | 4 that participates in the [tracing |
5 ecosystem](https://github.com/domokit/mojo/blob/master/mojo/services/tracing/pub
lic/interfaces/tracing.mojom) | 5 ecosystem](https://github.com/domokit/mojo/blob/master/mojo/services/tracing/pub
lic/interfaces/tracing.mojom) |
6 with no app changes required. | 6 with no app changes required. |
7 | 7 |
8 The script reads a list of benchmarks to run from a file, runs each benchmark in | 8 The script reads a list of benchmarks to run from a file, runs each benchmark in |
9 controlled caching conditions with tracing enabled and performs specified | 9 controlled caching conditions with tracing enabled and performs specified |
10 measurements on the collected trace data. | 10 measurements on the collected trace data. |
(...skipping 20 matching lines...) Expand all Loading... |
31 ``` | 31 ``` |
32 | 32 |
33 The following types of measurements are available: | 33 The following types of measurements are available: |
34 | 34 |
35 - `time_until` - measures time until the first occurence of the specified event | 35 - `time_until` - measures time until the first occurence of the specified event |
36 - `avg_duration` - measures the average duration of all instances of the | 36 - `avg_duration` - measures the average duration of all instances of the |
37 specified event | 37 specified event |
38 | 38 |
39 ## Caching | 39 ## Caching |
40 | 40 |
41 The script runs each benchmark twice. The first run (**cold start**) clears the | 41 The script runs each benchmark twice. The first run (**cold start**) clears |
42 following caches before start: | 42 caches of the following apps on startup: |
43 | 43 |
44 - url_response_disk_cache | 44 - network_service.mojo |
| 45 - url_response_disk_cache.mojo |
45 | 46 |
46 The second run (**warm start**) runs immediately afterwards, without clearing | 47 The second run (**warm start**) runs immediately afterwards, without clearing |
47 any caches. | 48 any caches. |
48 | 49 |
49 ## Time origin | 50 ## Time origin |
50 | 51 |
51 The underlying benchmark runner records the time origin just before issuing the | 52 The underlying benchmark runner records the time origin just before issuing the |
52 connection call to the application being benchmarked. Results of `time_until` | 53 connection call to the application being benchmarked. Results of `time_until` |
53 measurements are relative to this time. | 54 measurements are relative to this time. |
54 | 55 |
55 ## Example | 56 ## Example |
56 | 57 |
57 For an app that records a trace event named "initialized" in category "my_app" | 58 For an app that records a trace event named "initialized" in category "my_app" |
58 once its initialization is complete, we can benchmark the initialization time of | 59 once its initialization is complete, we can benchmark the initialization time of |
59 the app (from the moment someone tries to connect to it to the app completing | 60 the app (from the moment someone tries to connect to it to the app completing |
60 its initialization) using the following benchmark file: | 61 its initialization) using the following benchmark file: |
61 | 62 |
62 ```python | 63 ```python |
63 benchmarks = [ | 64 benchmarks = [ |
64 { | 65 { |
65 'name': 'My app initialization', | 66 'name': 'My app initialization', |
66 'app': 'https://my_domain/my_app.mojo', | 67 'app': 'https://my_domain/my_app.mojo', |
67 'duration': 10, | 68 'duration': 10, |
68 'measurements': [ | 69 'measurements': [ |
69 'time_until/my_app/initialized', | 70 'time_until/my_app/initialized', |
70 ], | 71 ], |
71 }, | 72 }, |
72 ] | 73 ] |
73 ``` | 74 ``` |
OLD | NEW |