1 ;;; ports.bm --- Port I/O. -*- mode: scheme; coding: utf-8; -*-
3 ;;; Copyright (C) 2010 Free Software Foundation, Inc.
5 ;;; This program is free software; you can redistribute it and/or
6 ;;; modify it under the terms of the GNU Lesser General Public License
7 ;;; as published by the Free Software Foundation; either version 3, or
8 ;;; (at your option) any later version.
10 ;;; This program is distributed in the hope that it will be useful,
11 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ;;; GNU Lesser General Public License for more details.
15 ;;; You should have received a copy of the GNU Lesser General Public
16 ;;; License along with this software; see the file COPYING.LESSER. If
17 ;;; not, write to the Free Software Foundation, Inc., 51 Franklin
18 ;;; Street, Fifth Floor, Boston, MA 02110-1301 USA
20 (define-module (benchmarks ports)
21 #:use-module (benchmark-suite lib))
24 (with-fluids ((%default-port-encoding #f))
25 (open-input-string "hello, world")))
27 (define %utf8/ascii-port
28 (with-fluids ((%default-port-encoding "UTF-8"))
29 (open-input-string "hello, world")))
31 (define %utf8/wide-port
32 (with-fluids ((%default-port-encoding "UTF-8"))
33 (open-input-string "안녕하세요")))
36 (with-benchmark-prefix "peek-char"
38 (benchmark "latin-1 port" 700000
39 (peek-char %latin1-port))
41 (benchmark "utf-8 port, ascii character" 700000
42 (peek-char %utf8/ascii-port))
44 (benchmark "utf-8 port, Korean character" 700000
45 (peek-char %utf8/wide-port)))
47 (with-benchmark-prefix "read-char"
49 (benchmark "latin-1 port" 10000000
50 (read-char %latin1-port))
52 (benchmark "utf-8 port, ascii character" 10000000
53 (read-char %utf8/ascii-port))
55 (benchmark "utf-8 port, Korean character" 10000000
56 (read-char %utf8/wide-port)))
58 (with-benchmark-prefix "char-ready?"
60 (benchmark "latin-1 port" 10000000
61 (char-ready? %latin1-port))
63 (benchmark "utf-8 port, ascii character" 10000000
64 (char-ready? %utf8/ascii-port))
66 (benchmark "utf-8 port, Korean character" 10000000
67 (char-ready? %utf8/wide-port)))