summaryrefslogtreecommitdiff
path: root/benchmark-suite
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2014-05-28 23:00:20 +0200
committerLudovic Courtès <ludo@gnu.org>2014-05-28 23:00:20 +0200
commita41b07a34f7309dccb2140ed924d7cd1c63268f9 (patch)
treecab08583e7a9fc245f18346b662a8a7eca82d1ca /benchmark-suite
parenteb6ac6efcdb6fe72fdecb4aa7161e86d0e1d3282 (diff)
rdelim: Speed up 'read-string' (aka. 'get-string-all'.)
This yields a 20% improvement on the "read-string" benchmark. * module/ice-9/rdelim.scm (read-string): Rewrite as a 'case-lambda', with a tight loop around 'read-char', and without using 'read-string!'. * test-suite/tests/rdelim.test ("read-string")["longer than 100 chars, with limit"]: New test. * benchmark-suite/benchmarks/ports.bm ("rdelim")["read-string"]: New benchmark.
Diffstat (limited to 'benchmark-suite')
-rw-r--r--benchmark-suite/benchmarks/ports.bm10
1 files changed, 8 insertions, 2 deletions
diff --git a/benchmark-suite/benchmarks/ports.bm b/benchmark-suite/benchmarks/ports.bm
index 630ece290..f4da2609a 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, 2011, 2012 Free Software Foundation, Inc.
+;;; Copyright (C) 2010, 2011, 2012, 2014 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
@@ -89,4 +89,10 @@
(benchmark "read-line" 1000
(let ((port (with-fluids ((%default-port-encoding "UTF-8"))
(open-input-string str))))
- (sequence (read-line port) 1000)))))
+ (sequence (read-line port) 1000))))
+
+ (let ((str (large-string "Hello, world.\n")))
+ (benchmark "read-string" 200
+ (let ((port (with-fluids ((%default-port-encoding "UTF-8"))
+ (open-input-string str))))
+ (read-string port)))))