From 0ddc5d04e6922cdb35cdc3b033937ac26a4ac050 Mon Sep 17 00:00:00 2001
From: Slava Pestov <slava@slava-pestovs-macbook-pro.local>
Date: Sun, 7 Sep 2008 04:14:47 -0500
Subject: [PATCH] Tweak sockets benchmark

---
 basis/io/unix/sockets/sockets.factor   |  2 +-
 extra/benchmark/sockets/sockets.factor | 25 ++++++++++++++++---------
 2 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/basis/io/unix/sockets/sockets.factor b/basis/io/unix/sockets/sockets.factor
index 8e0cb570ef..50952dd217 100755
--- a/basis/io/unix/sockets/sockets.factor
+++ b/basis/io/unix/sockets/sockets.factor
@@ -67,7 +67,7 @@ M: object ((client)) ( addrspec -- fd )
 M: object (server) ( addrspec -- handle )
     [
         SOCK_STREAM server-socket-fd
-        dup handle-fd 10 listen io-error
+        dup handle-fd 128 listen io-error
     ] with-destructors ;
 
 : do-accept ( server addrspec -- fd sockaddr )
diff --git a/extra/benchmark/sockets/sockets.factor b/extra/benchmark/sockets/sockets.factor
index 66c9c11167..68e3a625a7 100755
--- a/extra/benchmark/sockets/sockets.factor
+++ b/extra/benchmark/sockets/sockets.factor
@@ -6,7 +6,7 @@ IN: benchmark.sockets
 
 SYMBOL: counter
 
-: number-of-requests 1 ;
+: number-of-requests 1000 ;
 
 : server-addr ( -- addr ) "127.0.0.1" 7777 <inet4> ;
 
@@ -31,12 +31,14 @@ SYMBOL: counter
     ] ignore-errors ;
 
 : simple-client ( -- )
-    server-addr ascii [
-        CHAR: b write1 flush
-        number-of-requests
-        [ CHAR: a dup write1 flush read1 assert= ] times
-        counter get count-down
-    ] with-client ;
+    [
+        server-addr ascii [
+            CHAR: b write1 flush
+            number-of-requests
+            [ CHAR: a dup write1 flush read1 assert= ] times
+        ] with-client
+    ] try
+    counter get count-down ;
 
 : stop-server ( -- )
     server-addr ascii [
@@ -52,8 +54,13 @@ SYMBOL: counter
         counter get await
         stop-server
         yield yield
-    ] time ;
+    ] benchmark . flush ;
 
-: socket-benchmarks ;
+: socket-benchmarks ( -- )
+    1 clients
+    10 clients
+    20 clients
+    40 clients
+    100 clients ;
 
 MAIN: socket-benchmarks