1 ;;; write.bm --- Exercise the printer. -*- Scheme -*-
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 write)
21 #:use-module (benchmark-suite lib))
25 (define %string-with-escapes
26 (list->string (map integer->char (iota %len))))
28 (define %string-without-escapes
29 (make-string %len #\a))
31 ;; Use Unicode-capable ports.
32 (fluid-set! %default-port-encoding "UTF-8")
35 (%make-void-port OPEN_WRITE))
38 (with-benchmark-prefix "write"
40 (benchmark "string with escapes" 50
41 (write %string-with-escapes %null))
43 (benchmark "string without escapes" 50
44 (write %string-without-escapes %null)))
46 (with-benchmark-prefix "display"
48 (benchmark "string with escapes" 1000
49 (display %string-with-escapes %null))
51 (benchmark "string without escapes" 1000
52 (display %string-without-escapes %null)))