profile.lisp 1.4 KB

1234567891011121314151617181920212223242526272829303132
  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 CCL profile functions ;;;;;;;;;;;;;;;;;;;;
  4. ;;;
  5. ;;; Usage: load and compile this file, then at REPL, type "profile:on". After
  6. ;;; running programs, type "profile:report" to get a profile listing.
  7. ;;; "profile:reset" clears counters
  8. ;;; "profil:off" turns of profiling
  9. (in-package #:profile)
  10. #-CCL (progn
  11. (defun on () (error "Not Yet"))
  12. (defun off () (error "Not Yet"))
  13. (defun report () (error "Not Yet"))
  14. (defun reset () (error "Not Yet")))
  15. #+CCL (progn
  16. (defun on ()
  17. (dolist (p '("MP4-ATOM" "MPEG" "AUDIO-STREAMS" "ID3-FRAME" "UTILS" "LOGGING" "ISO-639-2" "ABSTRACT-TAG" "FLAC-FRAME"))
  18. (let ((pkg (find-package p)))
  19. (mon:monitor-all pkg)
  20. (format t "Package ~a, ~:d~%" pkg (length mon:*monitored-functions*))))
  21. (format t "~&~&WARNING: YOU MUST TURN PROFILING OFF BEFORE RECOMPILING LIBRARY!!!~%"))
  22. (defun report (&key (sort-key :percent-time) (nested :exclusive))
  23. (mon:report :sort-key sort-key :nested nested :threshold 0.0 :names :all))
  24. (defun reset ()
  25. (mon:reset-all-monitoring))
  26. (defun off ()
  27. (mon:unmonitor)))