1 ;;; read.bm --- Exercise the reader. -*- Scheme -*-
3 ;;; Copyright (C) 2008 Free Software Foundation, Inc.
5 ;;; This program is free software; you can redistribute it and/or modify
6 ;;; it under the terms of the GNU General Public License as published by
7 ;;; the Free Software Foundation; either version 2, or (at your option)
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 General Public License for more details.
15 ;;; You should have received a copy of the GNU General Public License
16 ;;; along with this software; see the file COPYING. If not, write to
17 ;;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 ;;; Boston, MA 02110-1301 USA
20 (define-module (benchmarks read)
21 :use-module (benchmark-suite lib))
24 (define %files-to-load
25 ;; Various large Scheme files.
26 (map %search-load-path
27 '("ice-9/boot-9.scm" "ice-9/common-list.scm"
28 "ice-9/format.scm" "ice-9/optargs.scm"
29 "ice-9/session.scm" "ice-9/getopt-long.scm"
32 (define (load-file-with-reader file-name reader buffering)
33 (with-input-from-file file-name
35 (apply setvbuf (current-input-port) buffering)
36 (let loop ((sexp (reader)))
37 (if (eof-object? sexp)
41 (define (exercise-read buffering)
42 (for-each (lambda (file)
43 (load-file-with-reader file read buffering))
47 (with-benchmark-prefix "read"
49 (benchmark "_IONBF" 5 ;; this one is very slow
50 (exercise-read (list _IONBF)))
52 (benchmark "_IOLBF" 100
53 (exercise-read (list _IOLBF)))
55 (benchmark "_IOFBF 4096" 100
56 (exercise-read (list _IOFBF 4096)))
58 (benchmark "_IOFBF 8192" 100
59 (exercise-read (list _IOFBF 8192)))
61 (benchmark "_IOFBF 16384" 100
62 (exercise-read (list _IOFBF 16384))))