From ad2c7c9388d5bacb5bec9d09f5bd39565b4534dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Sun, 8 Mar 2009 16:38:51 +0100 Subject: [PATCH] Add new subr invocation benchmarks. * benchmark-suite/benchmarks/subr.bm (hook1, hook3): New variables. ("subr invocation")("generic subr with rest arg", "generic subr with rest arg and 3+ parameters"): New benchmarks. ("subr application")("generic subr with rest arg", "generic subr with rest arg and 3+ parameters"): New benchmarks. --- benchmark-suite/benchmarks/subr.bm | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/benchmark-suite/benchmarks/subr.bm b/benchmark-suite/benchmarks/subr.bm index fbb9ed386..9c87a9921 100644 --- a/benchmark-suite/benchmarks/subr.bm +++ b/benchmark-suite/benchmarks/subr.bm @@ -21,6 +21,9 @@ :use-module (benchmark-suite lib)) +(define hook1 (make-hook 1)) +(define hook3 (make-hook 3)) + (with-benchmark-prefix "subr invocation" (benchmark "simple subr" 700000 @@ -34,7 +37,18 @@ ;; closures" (cclos). There, when a cclo/gsubr is called, the evaluator ;; goes through `SCM_APPLY ()' and conses the arguments, which is more ;; costly than the invocation of a "simple subr". - (string= "foo" "bar"))) + (string= "foo" "bar")) + + (benchmark "generic subr with rest arg" 700000 + ;; 1 required argument, 0 optional arguments, 1 rest. + (run-hook hook1 1)) + + (benchmark "generic subr with rest arg and 3+ parameters" 700000 + ;; 1 required argument, 0 optional arguments, 1 rest. + + ;; The evaluator considers calls with 3 and more parameters as a general + ;; form and always stores the arguments into a list. + (run-hook hook3 1 2 3))) (with-benchmark-prefix "subr application" @@ -43,4 +57,10 @@ (apply 1+ '(0))) (benchmark "generic subr" 700000 - (apply string= "foo" '("bar")))) + (apply string= "foo" '("bar"))) + + (benchmark "generic subr with rest arg" 700000 + (apply run-hook hook1 '(1))) + + (benchmark "generic subr with rest arg and 3+ parameters" 700000 + (run-hook hook3 1 2 '(3))))