Updating built in Io code to use += instead of x = x + y
[io/quag.git] / addons / Socket / samples / WebServer / test.io
blob4033abb76f2abcc92e1b7a65389704a1f333249e
1 #!/usr/bin/env io
3 //debugCollector := 1
4 SocketManager setSelectTimeout(0.0)
5 Scheduler setSleepInterval(0)
7 requestCount := if(args at(0), args at(0) asNumber, 10000)
9 t1 := Date clone now
10 lastChunkTime := Date clone now
11 lastPause := 0
13 for (i, 1, requestCount,
14 socket := Socket clone setHost("127.0.0.1") setPort(8000)
15 socket setReadTimeout(.01) setConnectTimeout(.1)
16 socket connect
17 if (socket isOpen == nil, writeln(i, " failed connect"); continue)
18 socket write("GET /\r\n")
21 dt := (Date clone now - lastChunkTime) totalSeconds
22 //writeln(i)
23 if (dt > .1,
24 writeln(i, " paused for ", dt asString(1, 5), " seconds, diff: ", i - lastPause)
25 lastPause = i
27 lastChunkTime := Date clone now
29 socket close
32 dt := (Date clone now - t1) totalSeconds
33 writeln(requestCount, " requests in ", dt , " seconds")
34 writeln((requestCount / dt) floor, " requests per second")