;;; -*- mode: Lisp; Syntax: Common-Lisp; -*- ;;; ;;; Copyright (c) 2009 by the authors. ;;; ;;; See LICENCE for details. (in-package :hu.dwim.presentation) ;;;;;; ;;; frame-size-breakdown/widget ;; TODO: rewrite this using the meta gui (def (component e) frame-size-breakdown/widget (standard/widget) ((last-dynamic-usage 0) (last-descriptors nil))) (def render-xhtml frame-size-breakdown/widget (sb-ext:gc :full t) ;; TODO: room (bind ((last-dynamic-usage (last-dynamic-usage-of -self-)) (new-dynamic-usage (sb-kernel:dynamic-usage)) (last-descriptors (last-descriptors-of -self-)) (new-descriptors (collect-object-size-descriptors-for-retained-objects (root-component-of *frame*) :ignored-type '(or symbol standard-class standard-slot-definition standard-generic-function sb-vm::code-component))) (last-total-count 0) (last-total-size 0) (new-total-count 0) (new-total-size 0) (class-names (delete-duplicates (append (when last-descriptors (mapcar #'class-name-of last-descriptors)) (mapcar #'class-name-of new-descriptors))))) (setf (last-dynamic-usage-of -self-) new-dynamic-usage) (setf (last-descriptors-of -self-) new-descriptors) (labels ((last-descriptor-for (class-name) (find class-name last-descriptors :key #'class-name-of)) (new-descriptor-for (class-name) (find class-name new-descriptors :key #'class-name-of)) (average (size count) (if (zerop count) "N/A" (coerce (/ size count) 'float))) (render-cells (name last-count new-count last-size new-size) ))
>
>>> " :cl) ;; FIXME: hu.dwim.syntax-sugar breaks reading without find-symbol :key (lambda (class-name) (aif (new-descriptor-for class-name) (size-of it) 0)))) (for last-descriptor = (when last-descriptors (last-descriptor-for class-name))) (for last-count = (if last-descriptor (count-of last-descriptor) 0)) (for last-size = (if last-descriptor (size-of last-descriptor) 0)) (incf last-total-count last-count) (incf last-total-size last-size) (for new-descriptor = (new-descriptor-for class-name)) (for new-count = (if new-descriptor (count-of new-descriptor) 0)) (for new-size = (if new-descriptor (size-of new-descriptor) 0)) (incf new-total-count new-count) (incf new-total-size new-size) ) >>)))
>