Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
35
Task/Time-a-function/Seed7/time-a-function.seed7
Normal file
35
Task/Time-a-function/Seed7/time-a-function.seed7
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
$ include "seed7_05.s7i";
|
||||
include "time.s7i";
|
||||
include "duration.s7i";
|
||||
|
||||
const func integer: identity (in integer: x) is
|
||||
return x;
|
||||
|
||||
const func integer: sum (in integer: num) is func
|
||||
result
|
||||
var integer: result is 0;
|
||||
local
|
||||
var integer: number is 0;
|
||||
begin
|
||||
result := num;
|
||||
for number range 1 to 1000000 do
|
||||
result +:= number;
|
||||
end for;
|
||||
end func;
|
||||
|
||||
const func duration: timeIt (ref func integer: aFunction) is func
|
||||
result
|
||||
var duration: result is duration.value;
|
||||
local
|
||||
var time: before is time.value;
|
||||
begin
|
||||
before := time(NOW);
|
||||
ignore(aFunction);
|
||||
result := time(NOW) - before;
|
||||
end func;
|
||||
|
||||
const proc: main is func
|
||||
begin
|
||||
writeln("Identity(4) takes " <& timeIt(identity(4)));
|
||||
writeln("Sum(4) takes " <& timeIt(sum(4)));
|
||||
end func;
|
||||
Loading…
Add table
Add a link
Reference in a new issue