]> code.delx.au - gnu-emacs-elpa/commitdiff
Benchmark coloring time separately.
authorJackson Ray Hamilton <jackson@jacksonrayhamilton.com>
Sun, 14 Jun 2015 18:45:21 +0000 (11:45 -0700)
committerJackson Ray Hamilton <jackson@jacksonrayhamilton.com>
Sun, 14 Jun 2015 18:45:21 +0000 (11:45 -0700)
`elp-instrument-package' significantly affects the performance of
coloring.

benchmark/context-coloring-benchmark.el

index c2dd65316434a1b5929919dde988785bdfdf4b2b..1f5885c024ecabd9cde62b96e116d0b9dd98a2b7 100644 (file)
@@ -26,6 +26,7 @@
 ;;; Code:
 
 (require 'context-coloring)
+(require 'elp)
 (require 'js2-mode)
 
 
@@ -115,7 +116,6 @@ with STATISTICS."
 callbacks.  Measure the performance of all FIXTURES, calling
 CALLBACK when all are done."
   (funcall setup)
-  (elp-instrument-package "context-coloring-")
   (let ((result-file (context-coloring-benchmark-resolve-path
                       (format "./logs/results-%s-%s.log"
                               title (format-time-string "%s")))))
@@ -134,10 +134,12 @@ CALLBACK when all are done."
                original-function
                (lambda ()
                  (setq count (+ count 1))
-                 (push (- (float-time) colorization-start-time) colorization-times)
-                 ;; Test 5 times.
+                 ;; First 5 runs are for gathering real coloring times,
+                 ;; unaffected by elp instrumentation.
+                 (when (<= count 5)
+                   (push (- (float-time) colorization-start-time) colorization-times))
                  (cond
-                  ((= count 5)
+                  ((= count 10)
                    (advice-remove #'context-coloring-colorize advice)
                    (context-coloring-benchmark-log-results
                     result-file
@@ -148,8 +150,14 @@ CALLBACK when all are done."
                      :words (count-words (point-min) (point-max))
                      :colorization-times colorization-times
                      :average-colorization-time (/ (apply #'+ colorization-times) 5)))
+                   (elp-restore-all)
                    (kill-buffer)
                    (funcall callback))
+                  ;; The last 5 runs are for gathering function call and
+                  ;; duration statistics.
+                  ((= count 5)
+                   (elp-instrument-package "context-coloring-")
+                   (context-coloring-colorize))
                   (t
                    (setq colorization-start-time (float-time))
                    (context-coloring-colorize))))))))