# HG changeset patch # User Steve Losh # Date 1470409755 0 # Node ID 2a3b1544c78fae3426322da0e942446ec61f7058 # Parent e7b1f07365ed7420d68c2b54692864f7ac318fa9 Add profiling infrastructure diff -r e7b1f07365ed -r 2a3b1544c78f src/main.lisp --- a/src/main.lisp Fri Aug 05 15:09:09 2016 +0000 +++ b/src/main.lisp Fri Aug 05 15:09:15 2016 +0000 @@ -527,6 +527,36 @@ (make-algae x y))))) + +;;;; Profiling +(require :sb-sprof) +(sb-sprof::profile-call-counts "SILT") +(defvar *profiling* nil) + +(defun dump-profile () + (with-open-file (*standard-output* "silt.prof" + :direction :output + :if-exists :supersede) + (sb-sprof:report :type :graph + :sort-by :cumulative-samples + :sort-order :ascending) + (sb-sprof:report :type :flat + :min-percent 0.5))) + +(defun start-profiling () + (sb-sprof::reset) + (sb-sprof::start-profiling :max-samples 50000 + :mode :cpu + :sample-interval 0.005 + :threads :all) + (setf *profiling* t)) + +(defun stop-profiling () + (setf *profiling* nil) + (sb-sprof::stop-profiling) + (dump-profile)) + + ;;;; Game State Machine (defun render-title () (render @@ -742,3 +772,5 @@ (format t "Something went wrong, sorry.~%")))) ; (run) +; (start-profiling) +; (stop-profiling)