1 ;;; -*- mode: scheme; coding: utf-8; -*-
2 ;;; Integer arithmetic.
4 ;;; Copyright 2010, 2012 Free Software Foundation, Inc.
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.
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.
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
21 (define-module (benchmarks arithmetic)
22 #:use-module (benchmark-suite lib))
26 ;; Construct an expression of the form `(OP (OP (OP SEED)))', with a
29 ((_ (op x <>) seed count) ;; binary OP
30 (number? (syntax->datum #'count))
31 (let loop ((count (syntax->datum #'count))
36 (with-syntax ((result result))
38 ((_ (op <>) seed count) ;; unary OP
39 (number? (syntax->datum #'count))
40 (let loop ((count (syntax->datum #'count))
45 (with-syntax ((result result))
49 (with-benchmark-prefix "fixnum"
52 (repeat (1+ <>) 2 100))
55 (repeat (1- <>) 2 100))
58 (repeat (+ 2 <>) 7 100))
61 (repeat (- 2 <>) 7 100))
64 (repeat (* 1 <>) 1 100))
67 (repeat (/ 2 <>) 1 100)))