factor/extra/benchmark/dispatch3/dispatch3.factor

51 lines
1.1 KiB
Factor
Raw Normal View History

USING: alien.c-types sequences math mirrors splitting grouping
2008-09-10 23:11:40 -04:00
kernel make assocs alien.syntax columns
specialized-arrays bit-arrays ;
SPECIALIZED-ARRAY: double
2007-09-20 18:09:08 -04:00
IN: benchmark.dispatch3
GENERIC: g ( obj -- str )
M: assoc g drop "assoc" ;
M: sequence g drop "sequence" ;
M: virtual-sequence g drop "virtual-sequence" ;
M: number g drop "number" ;
M: object g drop "object" ;
: objects ( -- seq )
2007-09-20 18:09:08 -04:00
[
H{ } ,
\ + <mirror> ,
V{ 2 3 } ,
1 ,
10 >bignum ,
{ 1 2 3 } ,
"hello world" ,
SBUF" sbuf world" ,
V{ "a" "b" "c" } ,
double-array{ 1.0 2.0 3.0 } ,
2007-09-20 18:09:08 -04:00
"hello world" 4 tail-slice ,
10 f <repetition> ,
100 2 <sliced-groups> ,
"hello" <reversed> ,
f ,
{ { 1 2 } { 3 4 } } 0 <column> ,
?{ t f t } ,
B{ 1 2 3 } ,
[ "a" "b" "c" ] ,
1 [ + ] curry ,
123.456 ,
1/6 ,
C{ 1 2 } ,
ALIEN: 1234 ,
] { } make ;
: dispatch-test ( -- )
2007-09-20 18:09:08 -04:00
2000000 objects [ [ g drop ] each ] curry times ;
MAIN: dispatch-test