Time a function: Difference between revisions
→{{header|Wren}}: Now uses Benchmark class.
(Added solution for Action!) |
(→{{header|Wren}}: Now uses Benchmark class.) |
||
Line 2,636:
=={{header|Wren}}==
{{libheader|Wren-check}}
The only way Wren currently has to time a function (encapsulated in the ''Benchmark.run'' method) is to measure the System time before and after the function is called. We therefore use that approach, averaging over say 100 runs, having first shut down as many other processes as we can.
<lang ecmascript>import "./check" for Benchmark
for (i in 0..1e7) {}▼
Benchmark.run("a function", 100, true) {
▲ for (i in 0..1e7) {}
}</lang>
{{out}}
<pre>
Running 'a function' over 100 iteration(s):
-------------------------------------------
Best 191.172 ms
Mean 201.942 ms
Worst 208.049 ms
</pre>
|