Data update
This commit is contained in:
parent
4d5544505c
commit
4924dd0264
3073 changed files with 55820 additions and 4408 deletions
14
Task/Time-a-function/Agena/time-a-function.agena
Normal file
14
Task/Time-a-function/Agena/time-a-function.agena
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
scope # Time a function
|
||||
|
||||
local procedure timeFunction( f :: procedure ) :: number
|
||||
local startTime := os.clock();
|
||||
f();
|
||||
return os.clock() - startTime # execution time in milliseconds
|
||||
end;
|
||||
|
||||
local procedure toBeTimed()
|
||||
os.wait( 1.234 ) # sleep 1.234 seconds
|
||||
end
|
||||
|
||||
print( timeFunction( toBeTimed ) / 1000, " seconds" )
|
||||
end
|
||||
21
Task/Time-a-function/DuckDB/time-a-function.duckdb
Normal file
21
Task/Time-a-function/DuckDB/time-a-function.duckdb
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
# A table
|
||||
create or replace function countto(n) as (
|
||||
with recursive cte as (
|
||||
select 0 as ix
|
||||
union all
|
||||
select ix+1
|
||||
from cte
|
||||
where ix < n)
|
||||
select last(ix order by ix)
|
||||
from cte
|
||||
);
|
||||
|
||||
.timer on
|
||||
.print .timer is now on
|
||||
.print 10^4
|
||||
select length(range(0, 10_000));
|
||||
select countto(10 ^ 4);
|
||||
|
||||
.print 10^5
|
||||
select length(range(0, 100_000));
|
||||
select countto(10 ^ 5);
|
||||
22
Task/Time-a-function/Fennel/time-a-function.fennel
Normal file
22
Task/Time-a-function/Fennel/time-a-function.fennel
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
(do ;;; Time a function
|
||||
|
||||
(fn time-function [fn-to=be-timed]
|
||||
(local start-time (os.clock))
|
||||
(fn-to=be-timed)
|
||||
(- (os.clock) start-time) ;;; execution time in seconds
|
||||
)
|
||||
|
||||
(fn delay [delta-t]
|
||||
(local end-time (+ (os.clock) delta-t))
|
||||
(while (< (os.clock) end-time)
|
||||
(var x 0)
|
||||
(for [i 1 100_000] (set x (+ x 1)))
|
||||
)
|
||||
)
|
||||
|
||||
(fn test-fn []
|
||||
(delay 1.234) ; sleep 1.234 seconds
|
||||
)
|
||||
|
||||
(print (time-function test-fn " seconds"))
|
||||
)
|
||||
|
|
@ -2,7 +2,7 @@ function bench(Function, ...)
|
|||
local t = os.time()
|
||||
local clock1 = os.clock()
|
||||
Function(...)
|
||||
local c = os.clock()-clock
|
||||
local c = os.clock()-clock1
|
||||
return os.time()-t, c
|
||||
end
|
||||
|
||||
|
|
|
|||
14
Task/Time-a-function/Pluto/time-a-function.pluto
Normal file
14
Task/Time-a-function/Pluto/time-a-function.pluto
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
do -- Time a function
|
||||
|
||||
local function timeFunction( f : function ) : number
|
||||
local startTime = os.micros()
|
||||
f()
|
||||
return os.micros() - startTime
|
||||
end
|
||||
|
||||
local function toBeTimed() : void
|
||||
os.sleep( 1234 ) -- sleep 1.234 seconds
|
||||
end
|
||||
|
||||
print( $"{ timeFunction( toBeTimed ) / 1_000_000 } seconds" )
|
||||
end
|
||||
|
|
@ -1,10 +1,17 @@
|
|||
-- 22 Mar 2025
|
||||
arg count','prec
|
||||
-- 7 Aug 2025
|
||||
include Settings
|
||||
arg count','prec
|
||||
if count = '' then
|
||||
count = 1e7
|
||||
if prec = '' then
|
||||
prec = 9
|
||||
numeric digits prec
|
||||
|
||||
say 'TIME A FUNCTION'
|
||||
say version
|
||||
say
|
||||
say 'Part 1: REXX clauses'
|
||||
say
|
||||
call Parameters
|
||||
call DoLoop
|
||||
call DoForLoop
|
||||
|
|
@ -57,19 +64,23 @@ say
|
|||
call Stems
|
||||
say
|
||||
call Average
|
||||
say
|
||||
say 'Part 2: Profiler'
|
||||
say
|
||||
call Profiler 'ArcSin(X)',1/3
|
||||
call Profiler 'Exp(X)',1/4
|
||||
call Profiler 'Gamma(X)',1/5
|
||||
call Profiler 'Ln(X)',1/6
|
||||
call Profiler 'Pi()'
|
||||
call Profiler 'Sin(X)',1/7
|
||||
call Profiler 'Sqrt(X)',1/8
|
||||
call Profiler 'X',1/9
|
||||
call Profiler 'X**5-5/x-1',1/10
|
||||
call Profiler 'Zeta(X)',1/11
|
||||
return
|
||||
|
||||
Parameters:
|
||||
start = date() time()
|
||||
if count = '' then
|
||||
count = 1e6
|
||||
if prec = '' then
|
||||
prec = 9
|
||||
parse version version
|
||||
say 'Version' version
|
||||
say 'Using loop counter' count/1e6 'million and' Digits() 'digits'
|
||||
say
|
||||
numeric digits prec
|
||||
int1 = right(sqrt3(),prec%2); int2 = right(sqrt2(),prec%2)
|
||||
if int2 > int1 then
|
||||
parse value int2 int1 with int1 int2
|
||||
|
|
@ -478,6 +489,10 @@ else
|
|||
say Left(measure,20) 'cannot perform measure, please try a higher count'
|
||||
return
|
||||
|
||||
include Functions
|
||||
include Constants
|
||||
include Abend
|
||||
Profiler:
|
||||
arg ff,xx,yy,zz
|
||||
rr=Profile(ff,xx,yy,zz)
|
||||
say left(ff,10) 'takes' right(word(rr,2),4) 'microsec, x =' xx', f =' word(rr,1)/1
|
||||
return
|
||||
|
||||
include Math
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue