summaryrefslogtreecommitdiff
path: root/benchmark-suite
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2010-10-27 23:28:58 +0200
committerLudovic Courtès <ludo@gnu.org>2010-10-27 23:29:37 +0200
commit9cec275968d10144d77a8f0a449bb6725421628d (patch)
tree6b6363e0556e4bf2ef060d3b76773d84284c5fb8 /benchmark-suite
parent0b9bdb1b57340abbf4f091356da3a1af8d194197 (diff)
Augment `arithmetic.bm'.
* benchmark-suite/benchmarks/arithmetic.bm (repeat): Change the syntax. Add support for binary OP. ("fixnum")["1+", "1-"]: Adjust accordingly. ["+", "-"]: New benchmarks.
Diffstat (limited to 'benchmark-suite')
-rw-r--r--benchmark-suite/benchmarks/arithmetic.bm27
1 files changed, 21 insertions, 6 deletions
diff --git a/benchmark-suite/benchmarks/arithmetic.bm b/benchmark-suite/benchmarks/arithmetic.bm
index cd8bbbd7b..62d67be70 100644
--- a/benchmark-suite/benchmarks/arithmetic.bm
+++ b/benchmark-suite/benchmarks/arithmetic.bm
@@ -23,13 +23,22 @@
(define-syntax repeat
(lambda (s)
- ;; Construct an expression of the form `(OP (OP (OP BODY)))', with a
+ ;; Construct an expression of the form `(OP (OP (OP SEED)))', with a
;; depth of COUNT.
- (syntax-case s ()
- ((_ op body count)
+ (syntax-case s (<>)
+ ((_ (op x <>) seed count) ;; binary OP
(number? (syntax->datum #'count))
(let loop ((count (syntax->datum #'count))
- (result #'body))
+ (result #'seed))
+ (if (= 0 count)
+ result
+ (loop (1- count)
+ (with-syntax ((result result))
+ #'(op x result))))))
+ ((_ (op <>) seed count) ;; unary OP
+ (number? (syntax->datum #'count))
+ (let loop ((count (syntax->datum #'count))
+ (result #'seed))
(if (= 0 count)
result
(loop (1- count)
@@ -40,7 +49,13 @@
(with-benchmark-prefix "fixnum"
(benchmark "1+" 1e7
- (repeat 1+ 2 100))
+ (repeat (1+ <>) 2 100))
(benchmark "1-" 1e7
- (repeat 1- 2 100)))
+ (repeat (1- <>) 2 100))
+
+ (benchmark "+" 1e7
+ (repeat (+ 2 <>) 7 100))
+
+ (benchmark "-" 1e7
+ (repeat (+ 2 <>) 7 100)))