add signal-slot benchmark & better graphs
benchmark.lisp
Fri Jun 19 17:31:27 CEST 2009 Tobias Rautenkranz <tobias@rautenkranz.ch>
* add signal-slot benchmark & better graphs
--- old-benchmark/benchmark.lisp 2014-10-30 07:07:06.000000000 +0100
+++ new-benchmark/benchmark.lisp 2014-10-30 07:07:06.000000000 +0100
@@ -7,7 +7,9 @@
(setf timings args))
function
arguments)
- (list :processor-cycles (getf timings :processor-cycles))))
+ (list :processor-cycles (getf timings :processor-cycles)
+ :system-run-time-us (getf timings :system-run-time-us)
+ :user-run-time-us (getf timings :user-run-time-us))))
(defun print-header (stream data)
(dolist (d (alexandria:plist-alist (first data)))
@@ -22,17 +24,31 @@
(format out "~S~T" (rest e)))
(format out "~%"))))
+(defun write-lisp-info (file)
+ (write-R-table
+ `((:type ,(lisp-implementation-type)
+ :version ,(lisp-implementation-version)
+ :arch ,(machine-type)
+ :os ,(software-type)
+ :os-version ,(software-version)
+ :cl-smoke-version ,(mb.sysdef::version-string (mb.sysdef:version-of (mb.sysdef:find-system :smoke)))))
+ file))
-(defun benchmark (function &rest args)
+(defun benchmark (function iterations)
(let ((data))
+ (dotimes (n 3)
+ (funcall function iterations)) ;; startup
(dotimes (n 20 data)
(sb-ext:gc :full t)
- (push (apply #'timing function args)
+ (push (nconc (list :iterations iterations)
+ (timing function iterations))
data))))
-(defun run-compare (name function cxx-function iterations)
- (let ((data (benchmark function iterations))
- (cxx-data (benchmark cxx-function iterations))
+(defun run-compare (name function cxx-function iterations multiplier)
+ (format t "running ~A." name)
+ (let ((data (prog1 (benchmark function iterations) (princ ".")))
+ (cxx-data (prog1 (benchmark cxx-function (* multiplier iterations))
+ (princ ".")))
(file (make-pathname :defaults name
:type "dat")))
(write-R-table data file)
@@ -40,14 +56,18 @@
(make-pathname :defaults file
:name (concatenate 'string
"cxx-"
- (pathname-name file))))))
+ (pathname-name file)))))
+ (terpri))
-(defun run ()
- (run-compare "overload" #'overload #'cl-smoke-benchmark-overload 1000)
+(defun run (&optional construct)
+ (write-lisp-info "info.dat")
+ (run-compare "signal-slot" #'signal-slot
+ #'cl-smoke-benchmark-signal-slot 5000 1000)
(run-compare "inline-call" #'inline-call
- #'cl-smoke-benchmark-byte-array-size 1000)
+ #'cl-smoke-benchmark-byte-array-size 50000 3000)
(run-compare "simple-call" #'simple-call
- #'cl-smoke-benchmark-simple-call 1000)
- (with-benchmark-cxx-construct (1000)
- (run-compare "construct" #'construct
- #'cl-smoke-benchmark-construct 1000)))
+ #'cl-smoke-benchmark-simple-call 50000 3000)
+ (when construct
+ (with-benchmark-cxx-construct ((* 50 1000))
+ (run-compare "construct" #'construct
+ #'cl-smoke-benchmark-construct 1000 50))))