factor/extra/benchmark/udp-echo0/udp-echo0.factor

24 lines
582 B
Factor
Raw Normal View History

2011-08-26 21:02:22 -04:00
! Copyright (C) 2011 John Benediktsson
2011-08-26 20:18:08 -04:00
! See http://factorcode.org/license.txt for BSD license
USING: accessors destructors fry io.binary io.sockets kernel
2011-08-26 20:18:08 -04:00
sequences ;
IN: benchmark.udp-echo0
2011-08-26 20:18:08 -04:00
: send/recv ( packet server client -- )
[ over over addr>> ] [ send ] bi* receive drop assert= ;
: udp-echo ( #times #bytes -- )
'[
_ iota [ _ >be ] map
"127.0.0.1" 0 <inet4> <datagram> &dispose
"127.0.0.1" 0 <inet4> <datagram> &dispose
2011-08-26 20:18:08 -04:00
[ send/recv ] 2curry each
] with-destructors ;
: udp-echo0 ( -- ) 10,000 1 udp-echo ;
MAIN: udp-echo0