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)))