NB.* bmks.ijs: basic machine compute and file benchmarks. NB. require 'mystats filefns' NB. coinsert 'fldir' NB. For "frdix" - indexed file read. NB. Floating-point arithmetic: fpArithmetic=: 3 : 0 arfp=. i.0 (y) 6!:2 'arfp=. arfp,6!:2 ''([:%.[:<:+:) 1000 1000?@$0''' (y) 6!:2 'arfp=. arfp,6!:2 ''([: +/ .*/ %."2) <:+:2 1000 1000?@$0''' arfp ) NB. Integer arithmetic: iat1=: (([: +/\ 0 { ]) +/ .* [: -/\ 1 { ]) * ([: +/\ 2 { ]) +/ .* [: -/\ 3 { ] intArithmetic=: 3 : 0 ari=. i.0 (y) 6!:2 'ari=. ari,6!:2 ''([: +/ .-/ +/\"2) <:2 1000 1000?@$3''' (y) 6!:2 'ari=. ari,6!:2 ''iat1 <:4 1000 1000?@$3''' ari ) NB. File writing and reading: fileWrite=: 3 : 0 fw=. i.0 [ fnms=. ('12345',~&.><'App100x1e'),&.><'.txt' for_fct. i.#fnms do. nw=. 10^>:fct (y) 6!:2 'fw=. fw,6!:2 ''nw&(4 : ''''y[(x$a.) fappend y'''')^:100]>fct{fnms''' end. fw; fnms fileRead=: 3 : 0 'y fnms'=. y [ frdtm=. i.0 for_outr. i. y do. for_fct. ?/2$#fnms do. NB. Scramble order to impede caching (y) 6!:2 'frdtm=. frdtm,6!:2 ''fread >fct{fnms''' end. end. frdtm ) rndIxRead=: 4 : 'fread y;stix,x<.>:?stix-~fsize y [ stix=. ?fsize y' multiIxRd=: 4 : 'y[x&rndIxRead y' fileRndRead=: 3 : 0 'y max fnms'=. y [ fxrd=. i.0 for_fct. i.#fnms do. (y) 6!:2 'fxrd=. fxrd,6!:2 ''(max&multiIxRd)^:100]>fct{fnms''' end. fxrd ) NB.* usus: usual stats: min, max, mean, standard deviation. usus=: 3 : 0 if. 0=L. y do. (]`|: @.(1<#$y))(<./,>./,mean (,`,: @.(1<#$y)) stddev) y else. (<./,>./,mean,stddev)&> y end. ) bmkSet=: 3 : 0 smoutput 'Starting: ',":qts'' arfp=: fpArithmetic y smoutput 'Floating-point arithmetic: min, max, mean, SD:' smoutput usus arfp ari=: intArithmetic y smoutput 'Integer arithmetic: min, max, mean, SD:' smoutput usus ari 'fwrtm fnms'=: fileWrite y smoutput 'File writes: min, max, mean, SD:' smoutput usus fwrtm frdtm=: fileRead y;:i.9 do. mm=. <:+:?(2$sz)$0 tm=. tm,6!:2 '(1 |. ] [ +/ .*~)^:10]mm' end. tm )