1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2017 Ludovic Courtès <ludo@gnu.org>
4 ;;; This file is part of GNU Guix.
6 ;;; GNU Guix is free software; you can redistribute it and/or modify it
7 ;;; under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 3 of the License, or (at
9 ;;; your option) any later version.
11 ;;; GNU Guix is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;; GNU General Public License for more details.
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
19 (define-module (guix profiling)
20 #:use-module (ice-9 match)
22 register-profiling-hook!))
26 ;;; Basic support for Guix-specific profiling.
32 (or (and=> (getenv "GUIX_PROFILING") string-tokenize)
35 "Return true if COMPONENT profiling is active."
36 (member component profiled))))
38 (define %profiling-hooks
39 ;; List of profiling hooks.
41 ("after-gc" after-gc-hook)
42 ((or "exit" #f) exit-hook))
43 (or (and=> (getenv "GUIX_PROFILING_EVENTS") string-tokenize)
46 (define (register-profiling-hook! component thunk)
47 "Register THUNK as a profiling hook for COMPONENT, a string such as
49 (when (profiled? component)
50 (for-each (lambda (hook)
51 (add-hook! hook thunk))