Skip to content

Commit f0bf4b2

Browse files
raisiqueirakt3k
andauthored
docs: update benchmark file reading example (#1268)
Co-authored-by: Yoshiya Hinosawa <[email protected]>
1 parent 26786eb commit f0bf4b2

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

runtime/reference/cli/bench.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ will be excluded from the measurement.
103103
```ts
104104
Deno.bench("foo", async (b) => {
105105
// Open a file that we will act upon.
106-
const file = await Deno.open("a_big_data_file.txt");
106+
using file = await Deno.open("a_big_data_file.txt");
107107

108108
// Tell the benchmarking tool that this is the only section you want
109109
// to measure.
@@ -114,13 +114,12 @@ Deno.bench("foo", async (b) => {
114114

115115
// End measurement here.
116116
b.end();
117-
118-
// Now we can perform some potentially time-consuming teardown that will not
119-
// taint out benchmark results.
120-
file.close();
121117
});
122118
```
123119

120+
The above example requires the `--allow-read` flag to run the benchmark:
121+
`deno bench --allow-read file_reading.ts`.
122+
124123
## Grouping and baselines
125124

126125
When registering a bench case, it can be assigned to a group, using

0 commit comments

Comments
 (0)