1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00

Add subr invocation benchmark.

* benchmark-suite/Makefile.am (SCM_BENCHMARKS): Add `subr.bm'.
This commit is contained in:
Ludovic Courtès 2009-03-02 00:18:34 +01:00
parent 113e7c253a
commit b786a5bbf8
2 changed files with 47 additions and 0 deletions

View file

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

View file

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