Merge commit '47ca15c7dffd14a82e75c1a0aeeaf2e77f3fa5b4'
[bpt/guile.git] / benchmark-suite / benchmarks / write.bm
CommitLineData
07f49ac7
LC
1;;; write.bm --- Exercise the printer. -*- Scheme -*-
2;;;
e9c3018c 3;;; Copyright (C) 2010 Free Software Foundation, Inc.
07f49ac7
LC
4;;;
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.
9;;;
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.
14;;;
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
19
e9c3018c 20(define-module (benchmarks write)
07f49ac7
LC
21 #:use-module (benchmark-suite lib))
22
23(define %len 50000)
24
25(define %string-with-escapes
26 (list->string (map integer->char (iota %len))))
27
28(define %string-without-escapes
29 (make-string %len #\a))
30
31;; Use Unicode-capable ports.
32(fluid-set! %default-port-encoding "UTF-8")
33
34(define %null
35 (%make-void-port OPEN_WRITE))
36
37\f
38(with-benchmark-prefix "write"
39
40 (benchmark "string with escapes" 50
41 (write %string-with-escapes %null))
42
43 (benchmark "string without escapes" 50
44 (write %string-without-escapes %null)))
45
46(with-benchmark-prefix "display"
47
48 (benchmark "string with escapes" 1000
49 (display %string-with-escapes %null))
50
51 (benchmark "string without escapes" 1000
52 (display %string-without-escapes %null)))