Data update

This commit is contained in:
Ingy döt Net 2025-06-11 20:16:52 -04:00
parent 72eb4943cb
commit 4d5544505c
2347 changed files with 62432 additions and 16731 deletions

View file

@ -1,12 +1,14 @@
function Test_Function()
for i = 1, 10000000 do
local s = math.log( i )
s = math.sqrt( s )
end
function bench(Function, ...)
local t = os.time()
local clock1 = os.clock()
Function(...)
local c = os.clock()-clock
return os.time()-t, c
end
t1 = os.clock()
Test_Function()
t2 = os.clock()
function sleep(n)
local start = os.time()
repeat until os.time()-start==n
end
print( os.difftime( t2, t1 ) )
print( bench(sleep, 2) )

View file

@ -1,27 +1,483 @@
/*REXX program displays the elapsed time for a REXX function (or subroutine). */
arg reps . /*obtain an optional argument from C.L.*/
if reps=='' then reps=100000 /*Not specified? No, then use default.*/
call time 'Reset' /*only the 1st character is examined. */
junk = silly(reps) /*invoke the SILLY function (below). */
/*───► CALL SILLY REPS also works.*/
-- 22 Mar 2025
arg count','prec
include Settings
/* The E is for elapsed time.*/
/* │ ─ */
/* ┌────◄───┘ */
/**/
/**/
say 'function SILLY took' format(time("E"),,2) 'seconds for' reps "iterations."
/**/
/**/
/* ┌────────►───────┘ */
/**/
/* The above 2 for the FORMAT function displays the time with*/
/* two decimal digits (rounded) past the decimal point). Using */
/* a 0 (zero) would round the time to whole seconds. */
exit /*stick a fork in it, we're all done. */
/*────────────────────────────────────────────────────────────────────────────*/
silly: procedure /*chew up some CPU time doing some silly stuff.*/
do j=1 for arg(1) /*wash, apply, lather, rinse, repeat. ··· */
@.j=random() date() time() digits() fuzz() form() xrange() queued()
end /*j*/
return j-1
say 'TIME A FUNCTION'
say version
say
call Parameters
call DoLoop
call DoForLoop
call DoToLoop
call DoForByLoop
call DoToByLoop
say
call Tarra
call IntegerAssign
call IntegerAdd
call IntegerMultiply
call IntegerDivide1
call IntegerDivide2
call IntegerRemainder
call IntegerPower
say
call FloatAssign
call FloatAdd
call FloatMultiply
call FloatDivide1
call FloatDivide2
call FloatRemainder
call FloatPower
call FloatFormula
say
call StringFunctions
call NumericFunctions
call DateFunctions
call TimeFunctions
say
call FixedParseVar
call DynamicParseVar
call ParseValue
say
call NoOperation
say
call IfThen
call SelectWhen
say
call CallProc
call CallProcParms
call CallRout
call CallRoutParms
say
call Interpreting
say
call Output
call Input
say
call Stems
say
call Average
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
float1 = sqrt3()/1; float2 = sqrt2()/1
tarra = 0; totelaps = 0; totcount = 0
return
DoLoop:
call Time('r')
do count
end
call Measure 'Do',1
return
DoForLoop:
call Time('r')
do n = 1 for count
end
call Measure 'Do for',1
return
DoToLoop:
call Time('r')
do n = 1 to count
end
call Measure 'Do to',1
return
DoForByLoop:
call Time('r')
do n = 1 for count by 1
end
call Measure 'Do for by',1
return
DoToByLoop:
call Time('r')
do n = 1 to count by 1
end
call Measure 'Do to by',1
return
Tarra:
call Time('r')
do n = 1 to 1e8
end
tarra = Time('e')*count/1e8
return
IntegerAssign:
call Time('r')
do n = 1 to count
a = int1
end
call Measure 'Integer assign',1
return
IntegerAdd:
call Time('r')
do n = 1 to count
a = int1+int2
end
call Measure 'Integer +',1
return
IntegerMultiply:
call Time('r')
do n = 1 to count
a = int1*int2
end
call Measure 'Integer *',1
return
IntegerDivide1:
call Time('r')
do n = 1 to count
a = int1/int2
end
call Measure 'Integer /',1
return
IntegerDivide2:
call Time('r')
do n = 1 to count
a = int1//int2
end
call Measure 'Integer //',1
return
IntegerRemainder:
call Time('r')
do n = 1 to count
a = int1%int2
end
call Measure 'Integer %',1
return
IntegerPower:
call Time('r')
do n = 1 to count
a = int1**2
end
call Measure 'Integer **',1
return
FloatAssign:
call Time('r')
do n = 1 to count
a = float1
end
call Measure 'Float assign',1
return
FloatAdd:
call Time('r')
do n = 1 to count
a = float1+float2
end
call Measure 'Float +',1
return
FloatMultiply:
call Time('r')
do n = 1 to count
a = float1*float2
end
call Measure 'Float *',1
return
FloatDivide1:
call Time('r')
do n = 1 to count
a = float1/float2
end
call Measure 'Float /',1
return
FloatDivide2:
call Time('r')
do n = 1 to count
a = float1//float2
end
call Measure 'Float //',1
return
FloatRemainder:
call Time('r')
do n = 1 to count
a = float1%float2
end
call Measure 'Float %',1
return
FloatPower:
call Time('r')
do n = 1 to count
a = float1**2
end
call Measure 'Float **',1
return
FloatFormula:
call Time('r')
do n = 1 to count
a = (float1+float2) + (float1*float2) + (float1/float2)
end
call Measure 'Float formula',1
return
StringFunctions:
a = 'This is the first text'; b = 'This is the second text'; c = float1
call Time('r')
do n = 1 to count
t = a||b
t = Abbrev('text',a)
t = Center(a,100)
t = Compare(a,b)
t = Copies(a,3)
t = Delstr(a,5,10)
t = Delword(a,2,3)
t = Format(c,1,5)
t = Insert(a,b,10)
t = Lastpos('text',a)
t = Left(a,10)
t = Length(a)
t = Overlay('xxx',a,3)
t = Pos('text',a)
t = Reverse(a)
t = Right(a,10)
t = Space(a)
t = Strip(a)
t = Substr(a,5,10)
t = Subword(a,2,2)
t = Translate(a,'xxx','the')
t = Verify(a,'the')
t = Word(a,3)
t = Wordindex(a,3)
t = Wordlength(a,3)
t = Wordpos('the',a)
t = Words(a)
t = Xrange('a','z')
end
call Measure 'String functions',28
return
NumericFunctions:
call Time('r')
do n = 1 to count
t = Abs(float1)
t = Max(float1,float2)
t = Min(float1,float2)
t = Random()
t = Sign(float1)
t = Trunc(float1)
t = Digits()
end
call Measure 'Numeric functions',7
return
DateFunctions:
call Time('r')
do n = 1 to count
t = Date('b')
t = Date('d')
t = Date('e')
t = Date('m')
t = Date('n')
t = Date('o')
t = Date('s')
t = Date('u')
t = Date('w')
end
call Measure 'Date functions',9
return
TimeFunctions:
call Time('r')
do n = 1 to count
t = Time('c')
t = Time('e')
t = Time('h')
t = Time('l')
t = Time('m')
t = Time('n')
t = Time('s')
end
call Measure 'Time functions',7
return
FixedParseVar:
t = '1,2,3,4,5,6,7,8,9,10'
call Time('r')
do n = 1 to count
parse var t rec1 ',' rec2 ',' rec3 ',' rec4 ',' rec5 ',' rec6 ',' rec7 ',' rec8 ',' rec9 ',' rec10
end
call Measure 'Fixed parse var',1
return
DynamicParseVar:
t = '1,2,3,4,5,6,7,8,9,10'
call Time('r')
do n = 1 to count
do y = 1 to 10
parse var t rec.y ',' t
end
end
call Measure 'Dynamic parse var',1
return
Parsevalue:
call Time('r')
do n = 1 to count
parse value float1 float2 with a,b
end
call Measure 'Parse value',1
return
NoOperation:
call Time('r')
do n = 1 to count
nop
end
call Measure 'No operation',1
return
IfThen:
call Time('r')
do n = 1 to count
if float1 = float1 then nop
end
call Measure 'If then',1
return
SelectWhen:
call Time('r')
do n = 1 to count
select
when float1 = float1 then nop
end
end
call Measure 'Select when',1
return
CallProc:
call Time('r')
do n = 1 to count
call Proc1
end
call Measure 'Call procedure',1
return
CallProcParms:
call Time('r')
do n = 1 to count
call Proc2 1,2,3
end
call Measure 'Call procedure arg',1
return
CallRout:
call Time('r')
do n = 1 to count
call Rout1
end
call Measure 'Call routine',1
return
CallRoutParms:
call Time('r')
do n = 1 to count
call Rout2 1,2,3
end
call Measure 'Call routine arg',1
return
Proc1:
procedure
return
Proc2:
procedure
arg a,b,c
return
Rout1:
return
Rout2:
arg a,b,c
return
Interpreting:
a = 'nop'
call Time('r')
do n = 1 to count
interpret a
end
call Measure 'Interpret',1
return
Output:
file = 'dummy.txt'
call Lineout file,,1
call Time('r')
do n = 1 to count
call Lineout file,'Just a small line'
end
call Measure 'Output',1
return
Input:
file = 'dummy.txt'
call Time('r')
do n = 1 to count
t = Linein(file)
end
call Measure 'Input',1
return
Stems:
call Time('r')
do n = 1 to count
stem.n = n
end
call Measure 'Stem processing',1
return
Average:
totelaps = 1e6*totelaps/totcount
say Left('Average',20) round(totelaps,3) 'microsec =' round(1/totelaps,1) 'million clauses/sec'
say
say Left('Start run',20) start
say Left('Clauses processed',20) round(totcount/1e6,1) 'million'
say Left('Stop run',20) date() time()
return
Measure:
parse arg measure,clauses
elaps = Time('e')-tarra
if elaps > 0 then do
totelaps = totelaps+elaps; totcount = totcount+count*clauses
elaps = 1e6*elaps/(count*clauses)
say Left(measure,20) round(elaps,3) 'microsec =' round(1/elaps,1) 'million clauses/sec'
end
else
say Left(measure,20) 'cannot perform measure, please try a higher count'
return
include Functions
include Constants
include Abend

View file

@ -1,27 +0,0 @@
/*REXX program displays the elapsed time for a REXX function (or subroutine). */
arg reps . /*obtain an optional argument from C.L.*/
if reps=='' then reps=100000 /*Not specified? No, then use default.*/
call time 'Reset' /*only the 1st character is examined. */
junk = silly(reps) /*invoke the SILLY function (below). */
/*───► CALL SILLY REPS also works.*/
/* The J is for the CPU time used */
/* │ by the REXX program since */
/* ┌───────┘ since the time was RESET. */
/* │ This is a Regina extension.*/
/**/
say 'function SILLY took' format(time("J"),,2) 'seconds for' reps "iterations."
/**/
/**/
/* ┌────────►───────┘ */
/**/
/* The above 2 for the FORMAT function displays the time with*/
/* two decimal digits (rounded) past the decimal point). Using */
/* a 0 (zero) would round the time to whole seconds. */
exit /*stick a fork in it, we're all done. */
/*────────────────────────────────────────────────────────────────────────────*/
silly: procedure /*chew up some CPU time doing some silly stuff.*/
do j=1 for arg(1) /*wash, apply, lather, rinse, repeat. ··· */
@.j=random() date() time() digits() fuzz() form() xrange() queued()
end /*j*/
return j-1

View file

@ -1,485 +0,0 @@
Main:
call Parameters
call DoToLoops
call DoForLoops
call Tarra
call IntegerAssign
call IntegerAdd
call IntegerSubtract
call IntegerMultiply
call IntegerDivide1
call IntegerDivide2
call IntegerRemainder
call IntegerPower
call FloatingAssign
call FloatingAdd
call FloatingSubtract
call FloatingMultiply
call FloatingDivide1
call FloatingDivide2
call FloatingRemainder
call FloatingPower
call Formula
call StringFunctions
call NumericFunctions
call FixedParseVar
call DynamicParseVar
call NoOperation
call IfThen
call SelectWhen
call IfElseIf
call CallProc
call CallProcParms
call CallRout
call CallRoutParms
call DateTime
call PushPullQueued
call Interpreting
call Output
call Input
call StemProcessing
return
Parameters:
arg count digit
if count = '' then
count = 1e6
if digit = '' then
digit = 9
numeric digits digit
parse version version
say 'Version' version
say 'Using loop counter' count/1e6 'million and' digits() 'digits'
say
tarra = 0
call time('r')
return
DoToLoops:
call time('r')
do x = 1 to count*10
end
call Measure 'Do ... to ...',10
return
DoForLoops:
call time('r')
do x = 1 for count*10
end
call Measure 'Do ... for ...',10
return
Tarra:
call time('r')
do x = 1 to count*10
end
tarra = time('e')/10
return
IntegerAssign:
call time('r')
do x = 1 to count*10
a = 123
end
call Measure 'Integer assign',10
return
IntegerAdd:
call time('r')
do x = 1 to count*10
a = x+123
end
call Measure 'Integer +',10
return
IntegerSubtract:
call time('r')
do x = 1 to count*10
a = x-123
end
call Measure 'Integer -',10
return
IntegerMultiply:
call time('r')
do x = 1 to count*10
a = x*123
end
call Measure 'Integer *',10
return
IntegerDivide1:
call time('r')
do x = 1 to count*10
a = 123/3
end
call Measure 'Integer /',10
return
IntegerDivide2:
call time('r')
do x = 1 to count*10
a = x//123
end
call Measure 'Integer //',10
return
IntegerRemainder:
call time('r')
do x = 1 to count*10
a = x%123
end
call Measure 'Integer %',10
return
IntegerPower:
call time('r')
do x = 1 to count*10
a = 123**2
end
call Measure 'Integer **',10
return
FloatingAssign:
call time('r')
do x = 1 to count*10
a = 1.23
end
call Measure 'Floating assign',10
return
FloatingAdd:
call time('r')
do x = 1 to count*10
a = x+1.23
end
call Measure 'Floating +',10
return
FloatingSubtract:
call time('r')
do x = 1 to count*10
a = x-1.23
end
call Measure 'Floating -',10
return
FloatingMultiply:
call time('r')
do x = 1 to count*10
a = x*1.23
end
call Measure 'Floating *',10
return
FloatingDivide1:
call time('r')
do x = 1 to count*10
a = x/1.23
end
call Measure 'Floating /',10
return
FloatingDivide2:
call time('r')
do x = 1 to count*10
a = x//1.23
end
call Measure 'Floating //',10
return
FloatingRemainder:
call time('r')
do x = 1 to count*10
a = x%1.23
end
call Measure 'Floating %',10
return
FloatingPower:
call time('r')
do x = 1 to count*10
a = 1.23**2
end
call Measure 'Floating **',10
return
Formula:
call time('r')
do x = 1 to count
a = ( (x+1.23) * (x-1.23) ) / ( (x*1.23) * (x/1.23) )
end
call Measure 'Formula',1
return
StringFunctions:
a = 'this is the first text'; b = 'this is the second text'; c = 1.23
call time('r')
do x = 1 to count
t = a||b
t = abbrev('text',a)
t = center(a,100)
t = compare(a,b)
t = copies(a,3)
t = delstr(a,5,10)
t = delword(a,2,3)
t = format(c,1,2)
t = insert(a,b,10)
t = lastpos('text',a)
t = left(a,10)
t = length(a)
t = overlay('paul',a,4)
t = pos('text',a)
t = reverse(a)
t = right(a,10)
t = space(a)
t = strip(a)
t = substr(a,5,10)
t = subword(a,2,2)
t = translate(a,'one','the')
t = verify(a,'the')
t = word(a,3)
t = wordindex(a,3)
t = wordlength(a,3)
t = wordpos('is the',a)
t = words(a)
t = xrange('a','z')
end
call Measure 'String functions',28
return
NumericFunctions:
a = -1.23; b = 1.23
call time('r')
do x = 1 to count
t = abs(a)
t = max(a,b)
t = min(a,b)
t = random()
t = sign(a)
t = trunc(b)
t = digits()
end
call Measure 'Numeric functions',7
return
FixedParseVar:
t = '1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20'
call time('r')
do x = 1 to count
parse var t rec1 ',' rec2 ',' rec3 ',' rec4 ',' rec5 ',' rec6 ',' rec7 ',' rec8 ',' rec9 ',' rec10 ',',
rec11 ',' rec12 ',' rec13 ',' rec14 ',' rec15 ',' rec16 ',' rec17 ',' rec18 ',' rec19 ',' rec20 ','
end
call Measure 'Fixed parse var',1
return
DynamicParseVar:
t = '1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20'
call time('r')
do x = 1 to count
do y = 1 to 20
parse var t rec.y ',' t
end
end
call Measure 'Dynamic parse var',1
return
NoOperation:
call time('r')
do x = 1 to count*10
nop
end
call Measure 'No operation',10
return
IfThen:
a = 1
call time('r')
do x = 1 to count
if a = 1 then nop
if a = 2 then nop
if a <> 1 then nop
if a <> 2 then nop
if a < 0 then nop
if a < 2 then nop
if a > 0 then nop
if a > 2 then nop
end
call Measure 'If ...then ...',8
return
SelectWhen:
a = 2
call time('r')
do x = 1 to count
select
when a = 1 then nop
when a = 2 then nop
when a = 3 then nop
end
select
when a <> 2 then nop
when a <> 1 then nop
when a <> 0 then nop
end
select
when a > 2 then nop
when a > 1 then nop
when a > 0 then nop
end
select
when a < 2 then nop
when a < 3 then nop
when a < 4 then nop
end
end
call Measure 'Select ... when ...',8
return
IfElseIf:
a = 2
call time('r')
do x = 1 to count
if a = 1 then nop
else if a = 2 then nop
else if a = 3 then nop
if a <> 2 then nop
else if a <> 1 then nop
else if a <> 0 then nop
if a > 2 then nop
else if a > 1 then nop
else if a > 0 then nop
if a < 2 then nop
else if a < 3 then nop
else if a < 4 then nop
end
call Measure 'If ... else if ...',8
return
CallProc:
call time('r')
do x = 1 to count
call Proc1
end
call Measure 'Call procedure',1
return
CallProcParms:
call time('r')
do x = 1 to count
call Proc2 1,2,3
end
call Measure 'Call procedure with parms',1
return
CallRout:
call time('r')
do x = 1 to count
call Rout1
end
call Measure 'Call routine',1
return
CallRoutParms:
call time('r')
do x = 1 to count
call Rout2 1,2,3
end
call Measure 'Call routine with parms',1
return
Proc1:
procedure
return
Proc2:
procedure
arg a,b,c
return
Rout1:
return
Rout2:
arg a,b,c
return
DateTime:
call time('r')
do x = 1 to count
t = date('b')
t = date('d')
t = date('e')
t = date('m')
t = date('n')
t = date('o')
t = date('s')
t = date('u')
t = date('w')
t = time('c')
t = time('e')
t = time('h')
t = time('l')
t = time('m')
t = time('n')
t = time('s')
end
call Measure 'Date and time',16
return
PushPullQueued:
a = 123.45
call time('r')
do x = 1 to count
push a
b = queued()
pull a
end
call Measure 'Push, pull and queued',3
return
Interpreting:
a = 'nop'
call time('r')
do x = 1 to count
interpret a
end
call Measure 'Interpret',1
return
Output:
file = '\temp\perf.txt'
call lineout file,,1
call time('r')
do x = 1 to count
call lineout file,'sequence number of this record is' x
end
call Measure 'Output',1
return
Input:
file = '\temp\perf.txt'
call time('r')
do x = 1 to count
t = linein(file)
end
call Measure 'Input',1
return
StemProcessing:
call time('r')
do x = 1 to count
stem.x.x.x = 1.23
end
call Measure 'Stem processing',1
return
Measure:
parse arg measure,clauses
elaps = time('e')-tarra
if elaps > 0 then do
say left(measure,25) format((count*clauses)/(1e6*elaps) ,3,1) 'million clauses/sec'
end
else
say left(measure,25) 'loop counter too low, cannot perform measure'
return