extra: use map-sum in a few places.
parent
ffed1387ab
commit
742ed3bc21
|
@ -15,7 +15,7 @@ C: <transaction> transaction
|
|||
over transactions>> push ;
|
||||
|
||||
: total ( transactions -- balance )
|
||||
0 [ amount>> + ] reduce ;
|
||||
[ amount>> ] map-sum ;
|
||||
|
||||
: balance>> ( account -- balance ) transactions>> total ;
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ TUPLE: meeting-place count mailbox ;
|
|||
[ drop run-meeting-place ]
|
||||
|
||||
[ nip [ [ count>> number>string write bl ] [ self-count>> number>text write nl ] bi ] each ]
|
||||
[ nip 0 [ count>> + ] reduce bl number>chameneos-string print ]
|
||||
[ nip [ count>> ] map-sum bl number>chameneos-string print ]
|
||||
} 2cleave ;
|
||||
|
||||
! 6000000 for shootout, too slow right now
|
||||
|
|
|
@ -2,10 +2,10 @@ USING: kernel math math.constants msgpack sequences ;
|
|||
IN: benchmark.msgpack
|
||||
|
||||
: pack-sum ( seq -- n )
|
||||
0 [ >msgpack msgpack> + ] reduce ;
|
||||
[ >msgpack msgpack> ] map-sum ;
|
||||
|
||||
: pack-sum-lengths ( seq -- n )
|
||||
0 [ >msgpack msgpack> length + ] reduce ;
|
||||
[ >msgpack msgpack> length ] map-sum ;
|
||||
|
||||
: msgpack-benchmark ( -- )
|
||||
500,000 iota pack-sum 124,999,750,000 assert=
|
||||
|
|
Loading…
Reference in New Issue