Merge commit 'ca5e0414e96886177d883a249edd957d2331db65'
[bpt/guile.git] / benchmark-suite / benchmarks / srfi-1.bm
CommitLineData
0b7f2eb8
LC
1;;; -*- mode: scheme; coding: utf-8; -*-
2;;; SRFI-1.
3;;;
0a650678 4;;; Copyright 2010, 2011 Free Software Foundation, Inc.
0b7f2eb8
LC
5;;;
6;;; This program is free software; you can redistribute it and/or
7;;; modify it under the terms of the GNU Lesser General Public License
8;;; as published by the Free Software Foundation; either version 3, or
9;;; (at your option) any later version.
10;;;
11;;; This program is distributed in the hope that it will be useful,
12;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
13;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14;;; GNU Lesser General Public License for more details.
15;;;
16;;; You should have received a copy of the GNU Lesser General Public
17;;; License along with this software; see the file COPYING.LESSER. If
18;;; not, write to the Free Software Foundation, Inc., 51 Franklin
19;;; Street, Fifth Floor, Boston, MA 02110-1301 USA
20
21(define-module (benchmarks srfi-1)
22 #:use-module (srfi srfi-1)
23 #:use-module (benchmark-suite lib))
24
25(define %big-list
26 (iota 1000000))
27
28(define %small-list
29 (iota 10))
30
31\f
32(with-benchmark-prefix "fold"
33
d3cc00f6 34 (benchmark "big" 30
0b7f2eb8
LC
35 (fold (lambda (x y) y) #f %big-list))
36
d3cc00f6 37 (benchmark "small" 2000000
0b7f2eb8 38 (fold (lambda (x y) y) #f %small-list)))
dcde4386
LC
39
40\f
41(with-benchmark-prefix "drop-while"
42
43 (benchmark "big" 30
44 (drop-while (lambda (n) #t) %big-list))
45
46 (benchmark "small" 2000000
47 (drop-while (lambda (n) #t) %small-list)))
0a650678
AW
48
49(with-benchmark-prefix "map"
50
51 (benchmark "big" 30
52 (map (lambda (x) x) %big-list))
53
54 (benchmark "small" 2000000
55 (map (lambda (x) x) %small-list)))
56
57(with-benchmark-prefix "for-each"
58
59 (benchmark "big" 30
60 (for-each (lambda (x) #f) %big-list))
61
62 (benchmark "small" 2000000
63 (for-each (lambda (x) #f) %small-list)))
64