summaryrefslogtreecommitdiff
path: root/benchmark-suite
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2009-03-02 00:18:34 +0100
committerLudovic Courtès <ludo@gnu.org>2009-03-02 00:18:34 +0100
commitb786a5bbf825f61e04ccd9a54f93cb1e40ac67d9 (patch)
tree4148894d6e3a3b3560dabf8d7195bee3bd32b142 /benchmark-suite
parent113e7c253a5a795e33825c9085f6c36745afb702 (diff)
Add subr invocation benchmark.
* benchmark-suite/Makefile.am (SCM_BENCHMARKS): Add `subr.bm'.
Diffstat (limited to 'benchmark-suite')
-rw-r--r--benchmark-suite/Makefile.am1
-rw-r--r--benchmark-suite/benchmarks/subr.bm46
2 files changed, 47 insertions, 0 deletions
diff --git a/benchmark-suite/Makefile.am b/benchmark-suite/Makefile.am
index 5357cf050..e65e8bcb2 100644
--- a/benchmark-suite/Makefile.am
+++ b/benchmark-suite/Makefile.am
@@ -3,6 +3,7 @@ SCM_BENCHMARKS = benchmarks/0-reference.bm \
benchmarks/if.bm \
benchmarks/logand.bm \
benchmarks/read.bm \
+ benchmarks/subr.bm \
benchmarks/uniform-vector-read.bm
EXTRA_DIST = guile-benchmark lib.scm $(SCM_BENCHMARKS) \
diff --git a/benchmark-suite/benchmarks/subr.bm b/benchmark-suite/benchmarks/subr.bm
new file mode 100644
index 000000000..fbb9ed386
--- /dev/null
+++ b/benchmark-suite/benchmarks/subr.bm
@@ -0,0 +1,46 @@
+;;; subr.bm --- Measure the subr invocation cost. -*- Scheme -*-
+;;;
+;;; Copyright (C) 2009 Free Software Foundation, Inc.
+;;;
+;;; This program is free software; you can redistribute it and/or modify
+;;; it under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 2, or (at your option)
+;;; any later version.
+;;;
+;;; This program is distributed in the hope that it will be useful,
+;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with this software; see the file COPYING. If not, write to
+;;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;;; Boston, MA 02110-1301 USA
+
+(define-module (benchmarks subrs)
+ :use-module (benchmark-suite lib))
+
+
+(with-benchmark-prefix "subr invocation"
+
+ (benchmark "simple subr" 700000
+ ;; 1 required argument, 0 optional arguments, no rest.
+ (1+ 0))
+
+ (benchmark "generic subr" 700000
+ ;; 2 required arguments, 4 optional arguments, no rest.
+
+ ;; In Guile 1.8 and earlier, such subrs are implemented as "compiled
+ ;; 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")))
+
+
+(with-benchmark-prefix "subr application"
+
+ (benchmark "simple subr" 700000
+ (apply 1+ '(0)))
+
+ (benchmark "generic subr" 700000
+ (apply string= "foo" '("bar"))))