+(defun profiler-running-p (&optional mode)
+ "Return non-nil if the profiler is running.
+Optional argument MODE means only check for the specified mode (cpu or mem)."
+ (cond ((eq mode 'cpu) (and (fboundp 'profiler-cpu-running-p)
+ (profiler-cpu-running-p)))
+ ((eq mode 'mem) (profiler-memory-running-p))
+ (t (or (profiler-running-p 'cpu)
+ (profiler-running-p 'mem)))))
+