defconst, defvar: proclaim special at compile-time
[bpt/guile.git] / benchmark-suite / benchmarks / structs.bm
CommitLineData
f680bdd7
LC
1;;; -*- mode: scheme; coding: iso-8859-1; -*-
2;;; Structs.
3;;;
4;;; Copyright 2009 Free Software Foundation, Inc.
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 structs)
22 :use-module (benchmark-suite lib))
23
24;; Note: Use `--iteration-factor' to change this.
25(define iterations 2000000)
26
27(define vtable2
28 (make-vtable "prpr"))
29
30(define vtable7
31 (make-vtable (string-concatenate (make-list 7 "pr"))))
32
33\f
34(with-benchmark-prefix "constructors"
35
36 (benchmark "make-struct2 (opcode)" iterations
37 (make-struct vtable2 0 1 2))
38
39 (benchmark "make-struct2 (procedure)" iterations
40 (let ((s make-struct))
41 (s vtable2 0 1 2)))
42
43 (benchmark "make-struct7 (opcode)" iterations
44 (make-struct vtable7 0 1 2 3 4 5 6 7))
45
46 (benchmark "make-struct7 (procedure)" iterations
47 (let ((s make-struct))
48 (s vtable7 0 1 2 3 4 5 6 7))))
49
50\f
51(with-benchmark-prefix "pairs" ;; for comparison
52
53 (benchmark "cons (opcode)" iterations
54 (cons 1 2))
55
56 (benchmark "cons (procedure)" iterations
57 (let ((c cons))
58 (c 1 2)))
59
60 (benchmark "list (opcode)" iterations
61 (list 1 2 3 4 5 6 7))
62
63 (benchmark "list (procedure)" iterations
64 (let ((l list))
65 (l 1 2 3 4 5 6 7)))
66
67 (benchmark "make-list" iterations
68 (make-list 7)))