From 6c8684dc7d39ad535cdd9c34e004b2f1bf63cb02 Mon Sep 17 00:00:00 2001
From: Yuanle Song <sylecn@gmail.com>
Date: Wed, 25 Jan 2017 22:51:14 +0800
Subject: [PATCH] update racket-postgres/ benchmark

use query-rows in select bench
---
 README.org                 | 24 ++++++++++++++++++++++--
 racket-postgres/.gitignore |  1 +
 racket-postgres/bench.rkt  |  2 +-
 3 files changed, 24 insertions(+), 3 deletions(-)
 create mode 100644 racket-postgres/.gitignore

diff --git a/README.org b/README.org
index e6d3541..93bd60f 100644
--- a/README.org
+++ b/README.org
@@ -28,12 +28,12 @@ all build is release mode (with -O or equivalent).
 | pg9.4 | haskell/ghc7.10.3 | postgresql-simple |       0.61 |       26.6 |
 | pg9.4 | rust/rust1.13.0   | postgres          |       0.50 |       26.3 |
 | pg9.4 | go/go1.7.3        | pq                |       0.37 |       27.2 |
-| pg9.4 | racket/racket6.5  | built-in db       |       2.19 |       26.7 |
+| pg9.4 | racket/racket6.5  | built-in db       |       1.99 |       26.7 |
 
 - Remarks:
   - python and go's db binding is as fast as C.
   - rust and haskell is slower. C is 1.65x faster.
-  - racket is much slower. C is 6x faster.
+  - racket is much slower. C is 5x faster.
 
 ** postgres 9.4, cpython 2.7, psycopg2==2.6.1
 http://initd.org/psycopg/docs/usage.html
@@ -122,3 +122,23 @@ https://www.postgresql.org/docs/9.4/static/libpq.html
 
   So write performance is definitely testing disk IO performance. Read
   performance is related to the language and runtime.
+- try compile it with raco exe first.
+  2.00
+  27.84
+  --
+  2.02
+  27.62
+
+  it's about the same.
+
+- try use query-rows instead of query.
+  1.78
+  26.94
+  --
+  2.02
+  29.08
+  --
+  1.99
+  26.79
+
+  it's still the slowest.
diff --git a/racket-postgres/.gitignore b/racket-postgres/.gitignore
new file mode 100644
index 0000000..ba99195
--- /dev/null
+++ b/racket-postgres/.gitignore
@@ -0,0 +1 @@
+bench
diff --git a/racket-postgres/bench.rkt b/racket-postgres/bench.rkt
index 8dd7497..404d818 100644
--- a/racket-postgres/bench.rkt
+++ b/racket-postgres/bench.rkt
@@ -27,7 +27,7 @@
     (display (format "~as\n" (/ (- (current-inexact-milliseconds) start) 1000)))))
 
 (define (select-test)
-  (timeit (query pgc "SELECT id, bar FROM foo") TIMES))
+  (timeit (query-rows pgc "SELECT id, bar FROM foo") TIMES))
 
 (define (update-test)
   (timeit (query-exec pgc "UPDATE foo SET bar=bar+1 WHERE id=1") TIMES))
-- 
GitLab