Commit | Line | Data |
---|---|---|
aa51e98a LC |
1 | ;;; uniform-vector-read.bm --- Exercise binary I/O primitives. -*- Scheme -*- |
2 | ;;; | |
3 | ;;; Copyright (C) 2008 Free Software Foundation, Inc. | |
4 | ;;; | |
53befeb7 NJ |
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. | |
aa51e98a LC |
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 | |
53befeb7 | 13 | ;;; GNU Lesser General Public License for more details. |
aa51e98a | 14 | ;;; |
53befeb7 NJ |
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 | |
aa51e98a LC |
19 | |
20 | (define-module (benchmarks uniform-vector-read) | |
21 | :use-module (benchmark-suite lib) | |
22 | :use-module (srfi srfi-4)) | |
23 | ||
24 | (define file-name | |
25 | (tmpnam)) | |
26 | ||
27 | (define %buffer-size | |
28 | 7777) | |
29 | ||
30 | (define buf | |
31 | (make-u8vector %buffer-size)) | |
32 | ||
33 | (define str | |
34 | (make-string %buffer-size)) | |
35 | ||
36 | \f | |
37 | (with-benchmark-prefix "uniform-vector-read!" | |
38 | ||
9084db99 | 39 | (benchmark "uniform-vector-write" 4000 |
aa51e98a LC |
40 | (let ((output (open-output-file file-name))) |
41 | (uniform-vector-write buf output) | |
42 | (close output))) | |
43 | ||
9084db99 | 44 | (benchmark "uniform-vector-read!" 20000 |
aa51e98a LC |
45 | (let ((input (open-input-file file-name))) |
46 | (setvbuf input _IONBF) | |
47 | (uniform-vector-read! buf input) | |
48 | (close input))) | |
49 | ||
50 | (benchmark "string port" 5000 | |
51 | (let ((input (open-input-string str))) | |
52 | (uniform-vector-read! buf input) | |
53 | (close input)))) |