+
+ $callstack = $this->callstack();
+
+ if (!isset($this->callstack[$value][$callstack])) {
+ // Prevent ugly E_NOTICE
+ $this->callstack[$value][$callstack] = 0;
+ }
+
+ $this->callstack[$value][$callstack] += (float)$duration;
+
+ }
+
+ /**
+ * @brief Returns a string with a callstack. Can be used for logging.
+ *
+ * @return string
+ */
+ function callstack() {
+ $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 6);
+
+ // We remove the first two items from the list since they contain data that we don't need.
+ array_shift($trace);
+ array_shift($trace);
+
+ $callstack = array();
+ foreach ($trace AS $func)
+ $callstack[] = $func["function"];
+
+ return implode(", ", $callstack);