benchmark: update the example in the README.md

pull/5801/head
Delyan Angelov 2020-07-11 11:49:11 +03:00
parent ab3c1f2a08
commit 3aeca70970
1 changed files with 10 additions and 5 deletions

View File

@ -25,15 +25,20 @@ benchmarking of small snippets of code as *short*, easy to
write, and then to read and analyze the results, as possible. write, and then to read and analyze the results, as possible.
Example: Example:
```v ```v
import time
import benchmark import benchmark
b := benchmark.start() mut b := benchmark.start()
// your code 1 ... // your code section 1 ...
time.sleep_ms(1500)
b.measure('code_1') b.measure('code_1')
// your code 2 ... // your code section 2 ...
time.sleep_ms(500)
b.measure('code_2') b.measure('code_2')
``` ```
... which will produce on stdout something like this: ... which will produce on stdout something like this:
SPENT 17 ms in code_1 ```text
SPENT 462 ms in code_2 SPENT 1500.063 ms in code_1
SPENT 500.061 ms in code_2
```