File tree 1 file changed +7
-5
lines changed
1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ Additionally, these measurements will show up in your browser's profiler's
13
13
This API wraps both the `time` and `timeEnd` calls into a single type
14
14
named `ConsoleTimer`, ensuring both are called.
15
15
16
- ## Scoped measurement
16
+ ## Scoped Measurement
17
17
18
18
Wrap code to be measured in a closure with `ConsoleTimer::scope`.
19
19
@@ -26,7 +26,7 @@ let value = ConsoleTimer::scope("foo", || {
26
26
});
27
27
```
28
28
29
- ## RAII-style measurement
29
+ ## RAII-Style Measurement
30
30
31
31
For scenarios where `ConsoleTimer::scope` can't be used, like with
32
32
asynchronous operations, you can use `ConsoleTimer::new` to create a timer.
@@ -36,12 +36,14 @@ The measurement ends when the timer object goes out of scope / is dropped.
36
36
use gloo_console_timer::ConsoleTimer;
37
37
use gloo_timers::Timeout;
38
38
39
+ // Start timing a new operation.
40
+ let timer = ConsoleTimer::new("foo");
41
+
42
+ // And then asynchronously finish timing.
39
43
let timeout = Timeout::new(1_000, move || {
40
- let _timer = ConsoleTimer::new("foo");
41
- // Do some work which will be measured
44
+ drop(timer);
42
45
});
43
46
```
44
-
45
47
*/
46
48
47
49
#![ deny( missing_docs, missing_debug_implementations) ]
You can’t perform that action at this time.
0 commit comments