benchmarks: update for iota

db4
Slava Pestov 2010-01-15 07:08:22 +13:00
parent 2cd10e7166
commit 70fb7ba164
18 changed files with 33 additions and 33 deletions

View File

@ -4,7 +4,7 @@ USING: math sequences kernel base64 ;
IN: benchmark.base64
: base64-benchmark ( -- )
65535 [ 255 bitand ] "" map-as
65535 iota [ 255 bitand ] "" map-as
20 [ >base64 base64> ] times
drop ;

View File

@ -8,7 +8,7 @@ IN: benchmark.dawes
: count-ones ( int-array -- n ) [ 1 = ] count ; inline
: make-int-array ( -- int-array )
120000 [ 255 bitand ] int-array{ } map-as ; inline
120000 iota [ 255 bitand ] int-array{ } map-as ; inline
: dawes-benchmark ( -- )
200 make-int-array '[ _ count-ones ] replicate drop ;

View File

@ -5,8 +5,8 @@ IN: benchmark.dispatch2
: sequences ( -- seq )
[
1 ,
10 >bignum ,
1 iota ,
10 >bignum iota ,
{ 1 2 3 } ,
"hello world" ,
SBUF" sbuf world" ,
@ -14,7 +14,7 @@ IN: benchmark.dispatch2
double-array{ 1.0 2.0 3.0 } ,
"hello world" 4 tail-slice ,
10 f <repetition> ,
100 2 <sliced-groups> ,
100 iota 2 <sliced-groups> ,
"hello" <reversed> ,
{ { 1 2 } { 3 4 } } 0 <column> ,
?{ t f t } ,

View File

@ -54,14 +54,14 @@ IN: benchmark.dispatch4
20000000 [
20 [
foobar-1 drop
] each
] each-integer
] times ;
: foobar-test-2 ( -- )
20000000 [
20 [
foobar-2 drop
] each
] each-integer
] times ;
MAIN: foobar-test-1

View File

@ -5,7 +5,7 @@ sequences ;
IN: benchmark.e-decimals
: 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 )
n [1,b] D: 1

View File

@ -2,7 +2,7 @@ USING: math math.private kernel sequences ;
IN: benchmark.empty-loop-2
: empty-loop-2 ( n -- )
[ drop ] each ;
iota [ drop ] each ;
: empty-loop-main ( -- )
50000000 empty-loop-2 ;

View File

@ -56,7 +56,7 @@ CONSTANT: homo-sapiens
chars nth-unsafe ; inline
: 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 write bl print ; inline
@ -72,7 +72,7 @@ CONSTANT: homo-sapiens
:: make-repeat-fasta ( k len alu -- k' )
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
: write-repeat-fasta ( n alu desc id -- )

View File

@ -3,6 +3,6 @@
USING: math sequences kernel ;
IN: benchmark.gc1
: gc1 ( -- ) 600000 [ >bignum 1 + ] map drop ;
: gc1 ( -- ) 600000 iota [ >bignum 1 + ] map drop ;
MAIN: gc1

View File

@ -25,7 +25,7 @@ IN: benchmark.knucleotide
: small-groups ( x n -- b )
swap
[ length swap - 1 + ] 2keep
[ length swap - 1 + iota ] 2keep
[ [ over + ] dip subseq ] 2curry map ;
: handle-table ( inputs n -- )

View File

@ -1,11 +1,11 @@
! Copyright (C) 2008 Slava Pestov.
! Copyright (C) 2008, 2010 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: math math.functions kernel io io.styles prettyprint
combinators hints fry namespaces sequences ;
IN: benchmark.partial-sums
! 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
: cube ( x -- y ) dup dup * * ; inline
: -1^ ( n -- -1/1 ) 2 mod 2 * 1 - ; inline

View File

@ -1,5 +1,5 @@
USING: io io.files io.files.temp io.encodings.ascii random
math.parser math ;
math.parser math sequences ;
IN: benchmark.random
: random-numbers-path ( -- path )
@ -7,7 +7,7 @@ IN: benchmark.random
: write-random-numbers ( n -- )
random-numbers-path ascii [
[ 200 random 100 - number>string print ] times
[ 200 iota random 100 - number>string print ] times
] with-file-writer ;
: random-main ( -- )

View File

@ -149,7 +149,7 @@ DEFER: create ( level c r -- scene )
[ oversampling /f ] bi@ 0.0 0.0 double-4-boa ;
: 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 )
[
@ -161,8 +161,8 @@ DEFER: create ( level c r -- scene )
[ [ swap cast-ray + ] with each ] with each ;
: pixel-grid ( -- grid )
size reverse [
size [
size iota reverse [
size iota [
[ size 0.5 * - ] bi@ swap size
0.0 double-4-boa
] with map

View File

@ -148,7 +148,7 @@ DEFER: create ( level c r -- scene )
[ oversampling /f ] bi@ 0.0 double-array{ } 3sequence ;
: 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 )
[
@ -160,8 +160,8 @@ DEFER: create ( level c r -- scene )
[ [ swap cast-ray + ] with each ] with each ;
: pixel-grid ( -- grid )
size reverse [
size [
size iota reverse [
size iota [
[ size 0.5 * - ] bi@ swap size
double-array{ } 3sequence
] with map

View File

@ -13,7 +13,7 @@ SYMBOL: done
] times ;
: send-messages ( messages target -- )
dupd [ send ] curry each [ receive drop ] times ;
[ dup iota ] dip [ send ] curry each [ receive drop ] times ;
: destroy-ring ( target -- )
done swap send [ done eq? ] receive-if drop ;

View File

@ -7,8 +7,8 @@ SPECIALIZED-ARRAY: double
IN: benchmark.spectral-norm
:: inner-loop ( u n quot -- seq )
n [| i |
n 0.0 [| j |
n iota [| i |
n iota 0.0 [| j |
u i j quot call +
] reduce
] double-array{ } map-as ; inline

View File

@ -9,7 +9,7 @@ TUPLE: point { x float } { y float } { z float } ;
TUPLE-ARRAY: point
: tuple-array-benchmark ( -- )
100 [
100 iota [
drop 5000 <point-array> [
[ 1 + ] change-x
[ 1 - ] change-y

View File

@ -2,6 +2,6 @@ USING: ui.gadgets.panes prettyprint io sequences ;
IN: benchmark.ui-panes
: ui-pane-benchmark ( -- )
<pane> <pane-stream> [ 10000 [ . ] each ] with-output-stream* ;
<pane> <pane-stream> [ 10000 iota [ . ] each ] with-output-stream* ;
MAIN: ui-pane-benchmark

View File

@ -27,9 +27,9 @@ STRUCT: yuv_buffer
h >>uv_height
w >>y_stride
w >>uv_stride
w h * [ 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/ [ dup * dup * ] B{ } map-as malloc-byte-array &free >>v ;
w h * iota [ dup * ] B{ } map-as malloc-byte-array &free >>y
w h * 2/ iota [ dup dup * * ] B{ } map-as malloc-byte-array &free >>u
w h * 2/ iota [ dup * dup * ] B{ } map-as malloc-byte-array &free >>v ;
: clamp ( n -- n )
255 min 0 max ; inline
@ -76,12 +76,12 @@ STRUCT: yuv_buffer
: yuv>rgb-row ( index rgb yuv y -- index )
over stride
pick y_width>>
pick y_width>> iota
[ yuv>rgb-pixel ] with with with with each ; inline
: yuv>rgb ( rgb yuv -- )
[ 0 ] 2dip
dup y_height>>
dup y_height>> iota
[ yuv>rgb-row ] with with each
drop ;