From xemacs-m  Sun Dec  8 14:58:50 1996
Received: from altair.xemacs.org (steve@xemacs.miranova.com [206.190.83.19]) by xemacs.cs.uiuc.edu (8.8.3/8.8.3) with ESMTP id OAA16479 for <xemacs-beta@xemacs.org>; Sun, 8 Dec 1996 14:58:48 -0600 (CST)
Received: (from steve@localhost)
          by altair.xemacs.org (8.8.4/8.8.4)
	  id NAA25757; Sun, 8 Dec 1996 13:08:37 -0800
Sender: steve@xemacs.org
To: xemacs-beta@xemacs.org
Subject: Additions to Shane Holder's bench.el
X-Url: http://www.miranova.com/%7Esteve/
Mail-Copies-To: never
X-Face: #!T9!#9s-3o8)*uHlX{Ug[xW7E7Wr!*L46-OxqMu\xz23v|R9q}lH?cRS{rCNe^'[`^sr5"
 f8*@r4ipO6Jl!:Ccq<xoV[Qz2u8<8-+Vwf2gzJ44lf_/y9OaQ`@#Q65{U4/TC)i2`~/M&QI$X>p:9I
 OSS'2{-)-4wBnVeg0S\O4Al@)uC[pD|+
X-Attribution: sb
From: Steven L Baur <steve@miranova.com>
Mime-Version: 1.0 (generated by tm-edit 7.95)
Content-Type: text/plain; charset=US-ASCII
Date: 08 Dec 1996 13:08:36 -0800
Message-ID: <m2sp5g4ucr.fsf@altair.xemacs.org>
Lines: 181
X-Mailer: Red Gnus v0.72/XEmacs 20.0

The results I've gotten so far have been disappointing.  XEmacs v20
without Mule is within 10% of the speed of XEmacs 19.15, but both are
a great deal slower than 19.14 which is not a speed demon.  I haven't
tested against 19.13.

Critical numbers we need compared are 19.14 performance versus 19.15 &
20.0 non-mule.

The additions I made allow for profiling with Ben's profile code (not
available in pre19.15), and multiple runs.

;;; sb-bench.el --- a crude benchmark for emacsen
;; Copyright (C) 1987,88,89,90,93,94,95,96 Free Software Foundation, Inc.

;; Author: Shane Holder <holder@rsn.hp.com>
;; Adapted-By: Steve Baur <steve@altair.xemacs.org>

;; This file is part of XEmacs.

;; XEmacs 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.

;; XEmacs 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 XEmacs; see the file COPYING.  If not, write to the Free
;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
;; 02111-1307, USA.

;;; Commentary:

;; Adapted from Shane Holder's bench.el by steve@altair.xemacs.org.

;; To run
;; At the shell prompt emacs -q  <= don't load users .emacs
;; M-x byte-compile-file "bench.el"
;; M-x load-file "bench.elc"
;; In the scratch buffer (bench)

;;; Code:

;; Use elp to profile benchmarks
(require 'elp)

(defvar bench-large-lisp-file "/usr/lib/xemacs/site-lisp/folding.el"
  "Large lisp file to use in benchmarks")

(defvar bench-sort-filename "/tmp/bench-"
  "File to be used in the sort benchmark")

(defvar bench-pre-bench-hook nil
  "Hook for individual bench mark initialization.")

(defvar bench-post-bench-hook nil
  "Hook for individual bench mark statistic collection.")

(defvar bench-mark-function-alist
  '((bench-mark-1 . "Tower of Hanoi")
    (bench-mark-2 . "Font Lock")
    (bench-mark-3 . "Large File scrolling")
    (bench-mark-4 . "Frame Creation")
    (bench-mark-6 . "Large File bytecompilation")))

(defvar bench-enabled-profiling t
  "If non-nil and the underlying emacs supports it, do function profiling.")

(defvar bench-mark-profile-buffer "*Profile*"
  "Buffer used for collection of profiling data.")

;-----------------------------------------------------------------------------
(defun bench-mark-1 ()
  "How long to complete the tower of hanoi."
  (hanoi 4))

;-----------------------------------------------------------------------------
(defun bench-mark-2 ()
  "How long to fonitfy a large file."
  (find-file bench-large-lisp-file)
  (font-lock-fontify-buffer))

;-----------------------------------------------------------------------------
(defun bench-mark-3 ()
  "How long does it take to scroll down through a large file."
  (let ((buffer-read-only t))
    (goto-char (point-min))
    (while (< (point) (point-max))
      (next-line 1)
      (sit-for 0))))

;-----------------------------------------------------------------------------
(defun bench-mark-4 ()
  "How quickly can emacs create a new frame."
  (make-frame))


;-----------------------------------------------------------------------------
(defun bench-init-mark-5 ()
  (setq bench-sort-filename (make-temp-name bench-sort-filename))
  (find-file bench-sort-filename))

(defun bench-mark-5 ()
  ; Sort something
)

;-----------------------------------------------------------------------------
(defun bench-mark-6 ()
  ; Byte compile a file
  (byte-compile-file bench-large-lisp-file)
)

;=============================================================================
(defun bench-init ()
  "Initialize profiling for bench marking package."
  (if (fboundp 'start-profiling)
      (let ((buf (get-buffer-create bench-mark-profile-buffer)))
	(erase-buffer buf)
	(when (profiling-active-p)
	  (stop-profiling)
	  (clear-profiling-info)))
    (message "Profiling not available in this XEmacs.")
    (sit-for 2)))

(defun bench-profile-start (test-name)
  "Turn on profiling for test `test-name'."
  (when (and bench-enabled-profiling
	     (fboundp 'start-profiling))
    (when (profiling-active-p)
      (stop-profiling))
    (let ((buf (get-buffer-create bench-mark-profile-buffer)))
      (save-excursion
	(set-buffer buf)
	(insert "Test `" test-name "'\n")
	(start-profiling)))))

(defun bench-profile-stop (test-name)
  "Turn off profiling for test `test-name'."
  (when (and bench-enabled-profiling
	     (fboundp 'stop-profiling))
    (stop-profiling)
    (let ((buf (get-buffer-create bench-mark-profile-buffer)))
      (save-excursion
	(set-buffer buf)
	(insert (with-output-to-string
		 (pretty-print-profiling-info)) "\n")))
    (clear-profiling-info)))

(add-hook 'bench-pre-bench-hook 'bench-profile-start)
(add-hook 'bench-post-bench-hook 'bench-profile-stop)

(defun bench (arg)
  "Run a series of benchmarks."
  (interactive "p")
  (elp-instrument-package "bench-mark") ;Only instrument functions
                                        ;beginning with bench-mark
  (bench-init)
  (let ((benches bench-mark-function-alist))
    (while benches
      (let ((test-name (cdar benches)))
	(run-hook-with-args 'bench-pre-bench-hook test-name)
	(let ((count arg))
	  (while (> count 0)
	    (funcall (caar benches))
	    (setq count (1- count))))
	(setq benches (cdr benches))
	(run-hook-with-args 'bench-post-bench-hook test-name))
      ))
  (elp-results)
)

;;; sb-bench.el ends here

-- 
steve@miranova.com baur
Unsolicited commercial e-mail will be billed at $250/message.
"Bill Clinton is a bore.  He doesn't have a creative bone in his
body."  -- David Brinkley

