You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+26-9
Original file line number
Diff line number
Diff line change
@@ -89,10 +89,6 @@ cargo solve <day>
89
89
90
90
The `solve` command runs your solution against real puzzle inputs. To run an optimized build of your code, append the `--release` flag as with any other rust program.
91
91
92
-
By default, `solve` executes your code once and shows the execution time. If you append the `--time` flag to the command, the runner will run your code between `10` and `10.000` times (depending on execution time of first execution) and print the average execution time.
93
-
94
-
For example, running a benchmarked, optimized execution of day 1 would look like `cargo solve 1 --release --time`. Displayed _timings_ show the raw execution time of your solution without overhead like file reads.
95
-
96
92
#### Submitting solutions
97
93
98
94
> [!IMPORTANT]
@@ -116,15 +112,36 @@ cargo all
116
112
# Total: 0.20ms
117
113
```
118
114
119
-
This runs all solutions sequentially and prints output to the command-line. Same as for the `solve` command, the `--release` flag runs an optimized build and the `--time` flag outputs benchmarks.
115
+
This runs all solutions sequentially and prints output to the command-line. Same as for the `solve` command, the `--release` flag runs an optimized build.
116
+
117
+
### ➡️ Benchmark your solutions
118
+
119
+
```sh
120
+
# example: `cargo time 8 --store`
121
+
cargo time<day> [--all] [--store]
122
+
123
+
# output:
124
+
# Day 08
125
+
# ------
126
+
# Part 1: 1 (39.0ns @ 10000 samples)
127
+
# Part 2: 2 (39.0ns @ 10000 samples)
128
+
#
129
+
# Total (Run): 0.00ms
130
+
#
131
+
# Stored updated benchmarks.
132
+
```
133
+
134
+
The `cargo time` command allows you to benchmark your code and store timings in the readme. When benching, the runner will run your code between `10` and `10.000` times, depending on execution time of first execution, and print the average execution time.
120
135
121
-
### ➡️ Update readme benchmarks
136
+
`cargo time` has three modes of execution:
122
137
123
-
The template can write benchmark times to the readme via the `cargo time` command.
138
+
1.`cargo time` without arguments incrementally benches solutions that do not have been stored in the readme yet and skips the rest.
139
+
2.`cargo time <day>` benches a single solution.
140
+
3.`cargo time --all` benches all solutions.
124
141
125
-
By default, this command checks for missing benchmarks, runs those solutions, and then updates the table. If you want to (re-)time all solutions, run `cargo time --all`. If you want to (re-)time one specific solution, run `cargo time <day>`.
142
+
By default, `cargo time` does not write to the readme. In order to do so, append the `--store` flag: `cargo time --store`.
126
143
127
-
Please note that these are not _scientific_ benchmarks, understand them as a fun approximation. 😉 Timings, especially in the microseconds range, might change a bit between invocations.
144
+
> Please note that these are not _scientific_ benchmarks, understand them as a fun approximation. 😉 Timings, especially in the microseconds range, might change a bit between invocations.
0 commit comments