mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-30 03:40:34 +02:00
Add a `read-line' benchmark.
* benchmark-suite/benchmarks/ports.bm ("rdelim"): New benchmark prefix.
This commit is contained in:
parent
e578faea20
commit
d9f24bc917
1 changed files with 22 additions and 1 deletions
|
@ -1,6 +1,6 @@
|
||||||
;;; ports.bm --- Port I/O. -*- mode: scheme; coding: utf-8; -*-
|
;;; 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
|
;;; This program is free software; you can redistribute it and/or
|
||||||
;;; modify it under the terms of the GNU Lesser General Public License
|
;;; modify it under the terms of the GNU Lesser General Public License
|
||||||
|
@ -18,6 +18,7 @@
|
||||||
;;; Street, Fifth Floor, Boston, MA 02110-1301 USA
|
;;; Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
(define-module (benchmarks ports)
|
(define-module (benchmarks ports)
|
||||||
|
#:use-module (ice-9 rdelim)
|
||||||
#:use-module (benchmark-suite lib))
|
#:use-module (benchmark-suite lib))
|
||||||
|
|
||||||
(define %latin1-port
|
(define %latin1-port
|
||||||
|
@ -65,3 +66,23 @@
|
||||||
|
|
||||||
(benchmark "utf-8 port, Korean character" 10000000
|
(benchmark "utf-8 port, Korean character" 10000000
|
||||||
(char-ready? %utf8/wide-port)))
|
(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))))))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue