profile.lisp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536
  1. ;;; -*- Mode: Lisp; show-trailing-whitespace: t; Base: 10; indent-tabs: nil; Syntax: ANSI-Common-Lisp; Package: PROFILE; -*-
  2. ;;; Copyright (c) 2013, Mark VandenBrink. All rights reserved.
  3. ;;;;;;;;;;;;;;;;;;;; Handy, dandy profile functions ;;;;;;;;;;;;;;;;;;;;
  4. ;;; "profile:on" enables profiling for taglib modules
  5. ;;; "profile:report" shows a profile listing
  6. ;;; "profile:reset" clears counters
  7. ;;; "profile:off" turns off profiling
  8. (in-package #:profile)
  9. #-CCL (progn
  10. (defun on () (error "Not Yet"))
  11. (defun off () (error "Not Yet"))
  12. (defun report () (error "Not Yet"))
  13. (defun reset () (error "Not Yet")))
  14. #+CCL (progn
  15. (defun on ()
  16. (let ((last-len 0)
  17. (cur-len 0))
  18. (dolist (p '("MP4-ATOM" "MPEG" "AUDIO-STREAMS" "ID3-FRAME" "UTILS" "ISO-639-2" "ABSTRACT-TAG" "FLAC-FRAME"))
  19. (let ((pkg (find-package p)))
  20. (mon:monitor-all pkg)
  21. (setf cur-len (length mon:*monitored-functions*))
  22. (format t "~4d functions/methods being monitored in package ~a~%" (- cur-len last-len) p)
  23. (setf last-len cur-len)))
  24. (format t "~4d total functions/methods being monitored~%" last-len))
  25. (format t "~&~%~%~%~&WARNING: you MUST turn profiling off before recompiling library, or weirdness will ensue!!!~%~%"))
  26. (defun report (&key (sort-key :percent-time) (nested :exclusive))
  27. (mon:report :sort-key sort-key :nested nested :threshold 0.0 :names :all))
  28. (defun reset ()
  29. (mon:reset-all-monitoring))
  30. (defun off ()
  31. (mon:unmonitor)))