summaryrefslogtreecommitdiff
path: root/benchmark-suite
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2011-01-26 23:02:41 +0100
committerLudovic Courtès <ludo@gnu.org>2011-01-26 23:03:17 +0100
commitd9f24bc91723182522c66157fc805f6ad2d4c4c6 (patch)
tree0a340bc2b34f194fa2d952791a2defdc57dfdb02 /benchmark-suite
parente578faea202a4e6eeb32e81e489b59119a2e02a0 (diff)
Add a `read-line' benchmark.
* benchmark-suite/benchmarks/ports.bm ("rdelim"): New benchmark prefix.
Diffstat (limited to 'benchmark-suite')
-rw-r--r--benchmark-suite/benchmarks/ports.bm23
1 files changed, 22 insertions, 1 deletions
diff --git a/benchmark-suite/benchmarks/ports.bm b/benchmark-suite/benchmarks/ports.bm
index 917a7ddbe..166cfa5f1 100644
--- a/benchmark-suite/benchmarks/ports.bm
+++ b/benchmark-suite/benchmarks/ports.bm
@@ -1,6 +1,6 @@
;;; ports.bm --- Port I/O. -*- mode: scheme; coding: utf-8; -*-
;;;
-;;; Copyright (C) 2010 Free Software Foundation, Inc.
+;;; Copyright (C) 2010, 2011 Free Software Foundation, Inc.
;;;
;;; This program is free software; you can redistribute it and/or
;;; modify it under the terms of the GNU Lesser General Public License
@@ -18,6 +18,7 @@
;;; Street, Fifth Floor, Boston, MA 02110-1301 USA
(define-module (benchmarks ports)
+ #:use-module (ice-9 rdelim)
#:use-module (benchmark-suite lib))
(define %latin1-port
@@ -65,3 +66,23 @@
(benchmark "utf-8 port, Korean character" 10000000
(char-ready? %utf8/wide-port)))
+
+
+(with-benchmark-prefix "rdelim"
+
+ (let-syntax ((sequence (lambda (s)
+ ;; Create a sequence `(begin EXPR ...)' with
+ ;; COUNT occurrences of EXPR.
+ (syntax-case s ()
+ ((_ expr count)
+ (number? (syntax->datum #'count))
+ (cons #'begin
+ (make-list
+ (syntax->datum #'count)
+ #'expr)))))))
+ (let ((str (string-concatenate
+ (make-list 1000 "one line\n"))))
+ (benchmark "read-line" 1000
+ (let ((port (with-fluids ((%default-port-encoding "UTF-8"))
+ (open-input-string str))))
+ (sequence (read-line port) 1000))))))