benchmarks: update for iota
parent
2cd10e7166
commit
70fb7ba164
|
@ -4,7 +4,7 @@ USING: math sequences kernel base64 ;
|
||||||
IN: benchmark.base64
|
IN: benchmark.base64
|
||||||
|
|
||||||
: base64-benchmark ( -- )
|
: base64-benchmark ( -- )
|
||||||
65535 [ 255 bitand ] "" map-as
|
65535 iota [ 255 bitand ] "" map-as
|
||||||
20 [ >base64 base64> ] times
|
20 [ >base64 base64> ] times
|
||||||
drop ;
|
drop ;
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ IN: benchmark.dawes
|
||||||
: count-ones ( int-array -- n ) [ 1 = ] count ; inline
|
: count-ones ( int-array -- n ) [ 1 = ] count ; inline
|
||||||
|
|
||||||
: make-int-array ( -- int-array )
|
: make-int-array ( -- int-array )
|
||||||
120000 [ 255 bitand ] int-array{ } map-as ; inline
|
120000 iota [ 255 bitand ] int-array{ } map-as ; inline
|
||||||
|
|
||||||
: dawes-benchmark ( -- )
|
: dawes-benchmark ( -- )
|
||||||
200 make-int-array '[ _ count-ones ] replicate drop ;
|
200 make-int-array '[ _ count-ones ] replicate drop ;
|
||||||
|
|
|
@ -5,8 +5,8 @@ IN: benchmark.dispatch2
|
||||||
|
|
||||||
: sequences ( -- seq )
|
: sequences ( -- seq )
|
||||||
[
|
[
|
||||||
1 ,
|
1 iota ,
|
||||||
10 >bignum ,
|
10 >bignum iota ,
|
||||||
{ 1 2 3 } ,
|
{ 1 2 3 } ,
|
||||||
"hello world" ,
|
"hello world" ,
|
||||||
SBUF" sbuf world" ,
|
SBUF" sbuf world" ,
|
||||||
|
@ -14,7 +14,7 @@ IN: benchmark.dispatch2
|
||||||
double-array{ 1.0 2.0 3.0 } ,
|
double-array{ 1.0 2.0 3.0 } ,
|
||||||
"hello world" 4 tail-slice ,
|
"hello world" 4 tail-slice ,
|
||||||
10 f <repetition> ,
|
10 f <repetition> ,
|
||||||
100 2 <sliced-groups> ,
|
100 iota 2 <sliced-groups> ,
|
||||||
"hello" <reversed> ,
|
"hello" <reversed> ,
|
||||||
{ { 1 2 } { 3 4 } } 0 <column> ,
|
{ { 1 2 } { 3 4 } } 0 <column> ,
|
||||||
?{ t f t } ,
|
?{ t f t } ,
|
||||||
|
|
|
@ -54,14 +54,14 @@ IN: benchmark.dispatch4
|
||||||
20000000 [
|
20000000 [
|
||||||
20 [
|
20 [
|
||||||
foobar-1 drop
|
foobar-1 drop
|
||||||
] each
|
] each-integer
|
||||||
] times ;
|
] times ;
|
||||||
|
|
||||||
: foobar-test-2 ( -- )
|
: foobar-test-2 ( -- )
|
||||||
20000000 [
|
20000000 [
|
||||||
20 [
|
20 [
|
||||||
foobar-2 drop
|
foobar-2 drop
|
||||||
] each
|
] each-integer
|
||||||
] times ;
|
] times ;
|
||||||
|
|
||||||
MAIN: foobar-test-1
|
MAIN: foobar-test-1
|
||||||
|
|
|
@ -5,7 +5,7 @@ sequences ;
|
||||||
IN: benchmark.e-decimals
|
IN: benchmark.e-decimals
|
||||||
|
|
||||||
: D-factorial ( n -- D! )
|
: D-factorial ( n -- D! )
|
||||||
D: 1 [ 0 <decimal> D: 1 D+ D* ] reduce ; inline
|
iota D: 1 [ 0 <decimal> D: 1 D+ D* ] reduce ; inline
|
||||||
|
|
||||||
:: calculate-e-decimals ( n -- e )
|
:: calculate-e-decimals ( n -- e )
|
||||||
n [1,b] D: 1
|
n [1,b] D: 1
|
||||||
|
|
|
@ -2,7 +2,7 @@ USING: math math.private kernel sequences ;
|
||||||
IN: benchmark.empty-loop-2
|
IN: benchmark.empty-loop-2
|
||||||
|
|
||||||
: empty-loop-2 ( n -- )
|
: empty-loop-2 ( n -- )
|
||||||
[ drop ] each ;
|
iota [ drop ] each ;
|
||||||
|
|
||||||
: empty-loop-main ( -- )
|
: empty-loop-main ( -- )
|
||||||
50000000 empty-loop-2 ;
|
50000000 empty-loop-2 ;
|
||||||
|
|
|
@ -56,7 +56,7 @@ CONSTANT: homo-sapiens
|
||||||
chars nth-unsafe ; inline
|
chars nth-unsafe ; inline
|
||||||
|
|
||||||
: make-random-fasta ( seed len chars floats -- seed )
|
: make-random-fasta ( seed len chars floats -- seed )
|
||||||
[ rot drop select-random ] 2curry "" map-as print ; inline
|
[ iota ] 2dip [ [ drop ] 2dip select-random ] 2curry "" map-as print ; inline
|
||||||
|
|
||||||
: write-description ( desc id -- )
|
: write-description ( desc id -- )
|
||||||
">" write write bl print ; inline
|
">" write write bl print ; inline
|
||||||
|
@ -72,7 +72,7 @@ CONSTANT: homo-sapiens
|
||||||
|
|
||||||
:: make-repeat-fasta ( k len alu -- k' )
|
:: make-repeat-fasta ( k len alu -- k' )
|
||||||
alu length :> kn
|
alu length :> kn
|
||||||
len [ k + kn mod alu nth-unsafe ] "" map-as print
|
len iota [ k + kn mod alu nth-unsafe ] "" map-as print
|
||||||
k len + ; inline
|
k len + ; inline
|
||||||
|
|
||||||
: write-repeat-fasta ( n alu desc id -- )
|
: write-repeat-fasta ( n alu desc id -- )
|
||||||
|
|
|
@ -3,6 +3,6 @@
|
||||||
USING: math sequences kernel ;
|
USING: math sequences kernel ;
|
||||||
IN: benchmark.gc1
|
IN: benchmark.gc1
|
||||||
|
|
||||||
: gc1 ( -- ) 600000 [ >bignum 1 + ] map drop ;
|
: gc1 ( -- ) 600000 iota [ >bignum 1 + ] map drop ;
|
||||||
|
|
||||||
MAIN: gc1
|
MAIN: gc1
|
||||||
|
|
|
@ -25,7 +25,7 @@ IN: benchmark.knucleotide
|
||||||
|
|
||||||
: small-groups ( x n -- b )
|
: small-groups ( x n -- b )
|
||||||
swap
|
swap
|
||||||
[ length swap - 1 + ] 2keep
|
[ length swap - 1 + iota ] 2keep
|
||||||
[ [ over + ] dip subseq ] 2curry map ;
|
[ [ over + ] dip subseq ] 2curry map ;
|
||||||
|
|
||||||
: handle-table ( inputs n -- )
|
: handle-table ( inputs n -- )
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
! Copyright (C) 2008 Slava Pestov.
|
! Copyright (C) 2008, 2010 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: math math.functions kernel io io.styles prettyprint
|
USING: math math.functions kernel io io.styles prettyprint
|
||||||
combinators hints fry namespaces sequences ;
|
combinators hints fry namespaces sequences ;
|
||||||
IN: benchmark.partial-sums
|
IN: benchmark.partial-sums
|
||||||
|
|
||||||
! Helper words
|
! Helper words
|
||||||
: summing-integers ( n quot -- y ) [ 0.0 ] 2dip '[ 1 + @ + ] each ; inline
|
: summing-integers ( n quot -- y ) [ 0.0 ] [ iota ] [ ] tri* '[ 1 + @ + ] each ; inline
|
||||||
: summing-floats ( n quot -- y ) '[ >float @ ] summing-integers ; inline
|
: summing-floats ( n quot -- y ) '[ >float @ ] summing-integers ; inline
|
||||||
: cube ( x -- y ) dup dup * * ; inline
|
: cube ( x -- y ) dup dup * * ; inline
|
||||||
: -1^ ( n -- -1/1 ) 2 mod 2 * 1 - ; inline
|
: -1^ ( n -- -1/1 ) 2 mod 2 * 1 - ; inline
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
USING: io io.files io.files.temp io.encodings.ascii random
|
USING: io io.files io.files.temp io.encodings.ascii random
|
||||||
math.parser math ;
|
math.parser math sequences ;
|
||||||
IN: benchmark.random
|
IN: benchmark.random
|
||||||
|
|
||||||
: random-numbers-path ( -- path )
|
: random-numbers-path ( -- path )
|
||||||
|
@ -7,7 +7,7 @@ IN: benchmark.random
|
||||||
|
|
||||||
: write-random-numbers ( n -- )
|
: write-random-numbers ( n -- )
|
||||||
random-numbers-path ascii [
|
random-numbers-path ascii [
|
||||||
[ 200 random 100 - number>string print ] times
|
[ 200 iota random 100 - number>string print ] times
|
||||||
] with-file-writer ;
|
] with-file-writer ;
|
||||||
|
|
||||||
: random-main ( -- )
|
: random-main ( -- )
|
||||||
|
|
|
@ -149,7 +149,7 @@ DEFER: create ( level c r -- scene )
|
||||||
[ oversampling /f ] bi@ 0.0 0.0 double-4-boa ;
|
[ oversampling /f ] bi@ 0.0 0.0 double-4-boa ;
|
||||||
|
|
||||||
: ss-grid ( -- ss-grid )
|
: ss-grid ( -- ss-grid )
|
||||||
oversampling [ oversampling [ ss-point ] with map ] map ;
|
oversampling iota [ oversampling iota [ ss-point ] with map ] map ;
|
||||||
|
|
||||||
: ray-grid ( point ss-grid -- ray-grid )
|
: ray-grid ( point ss-grid -- ray-grid )
|
||||||
[
|
[
|
||||||
|
@ -161,8 +161,8 @@ DEFER: create ( level c r -- scene )
|
||||||
[ [ swap cast-ray + ] with each ] with each ;
|
[ [ swap cast-ray + ] with each ] with each ;
|
||||||
|
|
||||||
: pixel-grid ( -- grid )
|
: pixel-grid ( -- grid )
|
||||||
size reverse [
|
size iota reverse [
|
||||||
size [
|
size iota [
|
||||||
[ size 0.5 * - ] bi@ swap size
|
[ size 0.5 * - ] bi@ swap size
|
||||||
0.0 double-4-boa
|
0.0 double-4-boa
|
||||||
] with map
|
] with map
|
||||||
|
|
|
@ -148,7 +148,7 @@ DEFER: create ( level c r -- scene )
|
||||||
[ oversampling /f ] bi@ 0.0 double-array{ } 3sequence ;
|
[ oversampling /f ] bi@ 0.0 double-array{ } 3sequence ;
|
||||||
|
|
||||||
: ss-grid ( -- ss-grid )
|
: ss-grid ( -- ss-grid )
|
||||||
oversampling [ oversampling [ ss-point ] with map ] map ;
|
oversampling iota [ oversampling iota [ ss-point ] with map ] map ;
|
||||||
|
|
||||||
: ray-grid ( point ss-grid -- ray-grid )
|
: ray-grid ( point ss-grid -- ray-grid )
|
||||||
[
|
[
|
||||||
|
@ -160,8 +160,8 @@ DEFER: create ( level c r -- scene )
|
||||||
[ [ swap cast-ray + ] with each ] with each ;
|
[ [ swap cast-ray + ] with each ] with each ;
|
||||||
|
|
||||||
: pixel-grid ( -- grid )
|
: pixel-grid ( -- grid )
|
||||||
size reverse [
|
size iota reverse [
|
||||||
size [
|
size iota [
|
||||||
[ size 0.5 * - ] bi@ swap size
|
[ size 0.5 * - ] bi@ swap size
|
||||||
double-array{ } 3sequence
|
double-array{ } 3sequence
|
||||||
] with map
|
] with map
|
||||||
|
|
|
@ -13,7 +13,7 @@ SYMBOL: done
|
||||||
] times ;
|
] times ;
|
||||||
|
|
||||||
: send-messages ( messages target -- )
|
: send-messages ( messages target -- )
|
||||||
dupd [ send ] curry each [ receive drop ] times ;
|
[ dup iota ] dip [ send ] curry each [ receive drop ] times ;
|
||||||
|
|
||||||
: destroy-ring ( target -- )
|
: destroy-ring ( target -- )
|
||||||
done swap send [ done eq? ] receive-if drop ;
|
done swap send [ done eq? ] receive-if drop ;
|
||||||
|
|
|
@ -7,8 +7,8 @@ SPECIALIZED-ARRAY: double
|
||||||
IN: benchmark.spectral-norm
|
IN: benchmark.spectral-norm
|
||||||
|
|
||||||
:: inner-loop ( u n quot -- seq )
|
:: inner-loop ( u n quot -- seq )
|
||||||
n [| i |
|
n iota [| i |
|
||||||
n 0.0 [| j |
|
n iota 0.0 [| j |
|
||||||
u i j quot call +
|
u i j quot call +
|
||||||
] reduce
|
] reduce
|
||||||
] double-array{ } map-as ; inline
|
] double-array{ } map-as ; inline
|
||||||
|
|
|
@ -9,7 +9,7 @@ TUPLE: point { x float } { y float } { z float } ;
|
||||||
TUPLE-ARRAY: point
|
TUPLE-ARRAY: point
|
||||||
|
|
||||||
: tuple-array-benchmark ( -- )
|
: tuple-array-benchmark ( -- )
|
||||||
100 [
|
100 iota [
|
||||||
drop 5000 <point-array> [
|
drop 5000 <point-array> [
|
||||||
[ 1 + ] change-x
|
[ 1 + ] change-x
|
||||||
[ 1 - ] change-y
|
[ 1 - ] change-y
|
||||||
|
|
|
@ -2,6 +2,6 @@ USING: ui.gadgets.panes prettyprint io sequences ;
|
||||||
IN: benchmark.ui-panes
|
IN: benchmark.ui-panes
|
||||||
|
|
||||||
: ui-pane-benchmark ( -- )
|
: ui-pane-benchmark ( -- )
|
||||||
<pane> <pane-stream> [ 10000 [ . ] each ] with-output-stream* ;
|
<pane> <pane-stream> [ 10000 iota [ . ] each ] with-output-stream* ;
|
||||||
|
|
||||||
MAIN: ui-pane-benchmark
|
MAIN: ui-pane-benchmark
|
||||||
|
|
|
@ -27,9 +27,9 @@ STRUCT: yuv_buffer
|
||||||
h >>uv_height
|
h >>uv_height
|
||||||
w >>y_stride
|
w >>y_stride
|
||||||
w >>uv_stride
|
w >>uv_stride
|
||||||
w h * [ dup * ] B{ } map-as malloc-byte-array &free >>y
|
w h * iota [ dup * ] B{ } map-as malloc-byte-array &free >>y
|
||||||
w h * 2/ [ dup dup * * ] B{ } map-as malloc-byte-array &free >>u
|
w h * 2/ iota [ dup dup * * ] B{ } map-as malloc-byte-array &free >>u
|
||||||
w h * 2/ [ dup * dup * ] B{ } map-as malloc-byte-array &free >>v ;
|
w h * 2/ iota [ dup * dup * ] B{ } map-as malloc-byte-array &free >>v ;
|
||||||
|
|
||||||
: clamp ( n -- n )
|
: clamp ( n -- n )
|
||||||
255 min 0 max ; inline
|
255 min 0 max ; inline
|
||||||
|
@ -76,12 +76,12 @@ STRUCT: yuv_buffer
|
||||||
|
|
||||||
: yuv>rgb-row ( index rgb yuv y -- index )
|
: yuv>rgb-row ( index rgb yuv y -- index )
|
||||||
over stride
|
over stride
|
||||||
pick y_width>>
|
pick y_width>> iota
|
||||||
[ yuv>rgb-pixel ] with with with with each ; inline
|
[ yuv>rgb-pixel ] with with with with each ; inline
|
||||||
|
|
||||||
: yuv>rgb ( rgb yuv -- )
|
: yuv>rgb ( rgb yuv -- )
|
||||||
[ 0 ] 2dip
|
[ 0 ] 2dip
|
||||||
dup y_height>>
|
dup y_height>> iota
|
||||||
[ yuv>rgb-row ] with with each
|
[ yuv>rgb-row ] with with each
|
||||||
drop ;
|
drop ;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue