This is a little off-topic but the question reminds me of a test I did
recently where I wanted to run something to see how many iterations I could
do in a certain amount of time:
NB.* doForTime: do verb for set number of seconds.
doForTime=: 1 : 0
tsEnd=. y+6!:1 '' NB. Time now + how many seconds to run
rr=. ''
while. tsEnd>6!:1 '' do. rr=. u rr end.
)
I compared how long iterating took this way versus using the power
conjunction:
f=: 3 : 'GBLCTR=: >:GBLCTR'
6!:2 'rr=. f doForTime 5'[GBLCTR=: 0
4.9889548
rr
577921
6!:2 'rr=. f^:577921]1'[GBLCTR=: 0
2.5145409
NB. Power conjunction twice as fast?
rr
577921
GBLCTR
577921
I also used this to time IO on different machines. The advantage is that I
could know in advance how long my timing would take:
NB. How fast is file append?
f=: 3 : ''' '' fappend ''C:\amisc\test.fl'''
ferase 'C:\amisc\test.fl'
1
6!:2 'rr=. f doForTime 5'
4.9914402
fsize 'C:\amisc\test.fl'
33450
ferase 'C:\amisc\test.fl'
1
6!:2 'rr=. f^:33450]1'
4.7571361
NB. Speed difference negligble if doing I/O.
On 11/25/07, Joey K Tuttle <[EMAIL PROTECTED]> wrote:
>
> I may be missing your point, but sdselect does take a time
> to wait argument -- from a thing that I worked out 5 years ago:
>
> require 'socket' NB. J system code for sockets
> ('jsocket';'jdefs';copath'base') copath 'base' NB. Just for
> convenience.
> NB. All names beginning with "sd" are from J system/main/socket.ijs
>
> .....
>
> NB. set up socket connections
> sdcleanup'' NB. Start with a clean slate er..r socket
> bs =: {.;sdcheck sdsocket '' NB. Get my Base Socket for listening.
> sdcheck sdbind bs;2;rip;port NB. bind my port, socket, etc.
> sdcheck sdlisten bs,3 NB. We listen (up to a max queue of 3)
>
> wait =: 60000 NB. Wait time in milliseconds - this is very arbitrary.
> while. (0=>0{sds =: sdselect bs;'';'';wait) do. NB. This could go
> on forever...
>
> happy to supply more (or the entire multi-socket listening
>
...
--
Devon McCormick, CFA
^me^ at acm.
org is my
preferred e-mail
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm