Permalink
Browse files

Add basic performance benchmark.

  • Loading branch information...
1 parent aa90f1e commit 392ec1a651cf29e7c3597510803ac33e792f9311 @kingcons committed Mar 13, 2013
Showing with 32 additions and 2 deletions.
  1. +3 −1 TODO
  2. +2 −1 cl-6502.asd
  3. +27 −0 tests/perf.lisp
View
4 TODO
@@ -1,4 +1,6 @@
-MOAR UNIT TESTS! (opcodes+macrology)
+Optimize!
+-- A third of our allocations running Klaus' testsuite is in OVERFLOW-P.
+-- Optimize status-bit% and generic-arithmetic calls CPU-time wise.
Fix the sexp assembler/disassembler for more addressing modes. (x,y)
-- substitute #\. #\, and remove whitespace?
-- add support for * insert program counter in assembly/disassembly?
View
@@ -29,7 +29,8 @@
(:file "assembler")
(:file "disassembler")
(:file "addressing")
- (:file "opcodes")))
+ (:file "opcodes")
+ #+sbcl (:file "perf")))
(defmethod operation-done-p ((op test-op)
(c (eql (find-system :cl-6502))))
View
@@ -0,0 +1,27 @@
+(in-package :6502-tests)
+
+(eval-when (:compile-toplevel :load-toplevel :execute)
+ (require 'sb-sprof))
+
+(def-suite performance :in 6502-tests)
+(in-suite performance)
+
+(defun profile-klaus-suite (&key (mode :time))
+ "MODE may be :TIME, :CPU, or :ALLOC. Load Klaus' test suite and use SBCL's
+statistical profiler to observe performance while running the test suite."
+ (klaus-init)
+ (sb-sprof:with-profiling (:max-samples 1000
+ :show-progress t
+ :report :graph
+ :mode mode
+ :reset t)
+ (loop until (> (cpu-cc *cpu*) (* 45 (expt 2 21)))
+ do (6502-step *cpu* (get-byte (immediate *cpu*))))))
+
+(deftest keep-it-fast
+ "We should not have deteriorating performance. 24.576 seconds at most."
+ ;; NOTE: This test based on 64-bit SBCL 1.1.4 on my Debian Thinkpad X200.
+ (klaus-init)
+ (let ((start (get-internal-real-time)))
+ (klaus-test)
+ (is (< (- (get-internal-real-time) start) #x6000))))

0 comments on commit 392ec1a

Please sign in to comment.