Time a function: Difference between revisions

m
→‎{{header|Wren}}: Changed to Wren S/H
(Added Easylang)
m (→‎{{header|Wren}}: Changed to Wren S/H)
 
(2 intermediate revisions by 2 users not shown)
Line 1,155:
=={{header|Elena}}==
{{trans|C#}}
ELENA 46.x :
<syntaxhighlight lang="elena">import system'calendar;
import system'routines;
Line 1,166:
threadControl.sleep(1000);
new Range(0,10000).filterBy::(x => x.mod:(2) == 0).summarize();
}
Line 2,610:
#11CAh SYSEVAL tick -
B→R 8192 / 1 FIX RND STD
≫ ≫ '<span style="color:blue">TEVAL</span>''TIMER'''’ STO
|
'''TIMER'''<span style="color:blue">TEVAL</span> ''( ≪function≫ -- execution_time )''
Store current system time
Execute function
Line 2,621:
{{in}}
<pre>
≪ 1 1000 START NEXT ≫ TIMERTEVAL
</pre>
{{out}}
Line 2,627:
1: 6.4
</pre>
Yes, more than 6 seconds to loop 1000 times is quite slow.
 
HP-49+ models have a built-in <code>TEVAL</code> command.
 
=={{header|Ruby}}==
Line 3,077 ⟶ 3,079:
{{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.
<syntaxhighlight lang="ecmascriptwren">import "./check" for Benchmark
 
Benchmark.run("a function", 100, true) {
9,482

edits