|
| 1 | +<?php |
| 2 | + |
| 3 | +/** |
| 4 | + * A collected series of stack traces and some utility methods to aggregate them. |
| 5 | + * |
| 6 | + * ExcimerLog acts as a container for ExcimerLogEntry objects. The Iterator or |
| 7 | + * ArrayAccess interfaces may be used to access them. For example: |
| 8 | + * |
| 9 | + * foreach ($profiler->getLog() as $entry) { |
| 10 | + * var_dump($entry->getTrace()); |
| 11 | + * } |
| 12 | + */ |
| 13 | +class ExcimerLog implements ArrayAccess, Iterator |
| 14 | +{ |
| 15 | + /** |
| 16 | + * ExcimerLog is not constructible by user code. Objects of this type |
| 17 | + * are available via: |
| 18 | + * - ExcimerProfiler::getLog() |
| 19 | + * - ExcimerProfiler::flush() |
| 20 | + * - The callback to ExcimerProfiler::setFlushCallback() |
| 21 | + */ |
| 22 | + final private function __construct() {} |
| 23 | + |
| 24 | + /** |
| 25 | + * Aggregate the stack traces and convert them to a line-based format |
| 26 | + * understood by Brendan Gregg's FlameGraph utility. Each stack trace is |
| 27 | + * represented as a series of function names, separated by semicolons. |
| 28 | + * After this identifier, there is a single space character, then a number |
| 29 | + * giving the number of times the stack appeared. Then there is a line |
| 30 | + * break. This is repeated for each unique stack trace. |
| 31 | + * |
| 32 | + * @return string |
| 33 | + */ |
| 34 | + public function formatCollapsed() {} |
| 35 | + |
| 36 | + /** |
| 37 | + * Produce an array with an element for every function which appears in |
| 38 | + * the log. The key is a human-readable unique identifier for the function, |
| 39 | + * method or closure. The value is an associative array with the following |
| 40 | + * elements: |
| 41 | + * |
| 42 | + * - self: The number of events in which the function itself was running, |
| 43 | + * no other userspace function was being called. This includes time |
| 44 | + * spent in internal functions that this function called. |
| 45 | + * - inclusive: The number of events in which this function appeared |
| 46 | + * somewhere in the stack. |
| 47 | + * |
| 48 | + * And optionally the following elements, if they are relevant: |
| 49 | + * |
| 50 | + * - file: The filename in which the function appears |
| 51 | + * - line: The exact line number at which the first relevant event |
| 52 | + * occurred. |
| 53 | + * - class: The class name in which the method is defined |
| 54 | + * - function: The name of the function or method |
| 55 | + * - closure_line: The line number at which the closure was defined |
| 56 | + * |
| 57 | + * The event counts in the "self" and "inclusive" fields are adjusted for |
| 58 | + * overruns. They represent an estimate of the number of profiling periods |
| 59 | + * in which those functions were present. |
| 60 | + * |
| 61 | + * @return array |
| 62 | + */ |
| 63 | + public function aggregateByFunction() {} |
| 64 | + |
| 65 | + /** |
| 66 | + * Get an array which can be JSON encoded for import into speedscope |
| 67 | + * |
| 68 | + * @return array |
| 69 | + */ |
| 70 | + public function getSpeedscopeData() {} |
| 71 | + |
| 72 | + /** |
| 73 | + * Get the total number of profiling periods represented by this log. |
| 74 | + * |
| 75 | + * @return int |
| 76 | + */ |
| 77 | + public function getEventCount() {} |
| 78 | + |
| 79 | + /** |
| 80 | + * Get the current ExcimerLogEntry object. Part of the Iterator interface. |
| 81 | + * |
| 82 | + * @return ExcimerLogEntry|null |
| 83 | + */ |
| 84 | + public function current() {} |
| 85 | + |
| 86 | + /** |
| 87 | + * Get the current integer key or null. Part of the Iterator interface. |
| 88 | + * |
| 89 | + * @return int|null |
| 90 | + */ |
| 91 | + public function key() {} |
| 92 | + |
| 93 | + /** |
| 94 | + * Advance to the next log entry. Part of the Iterator interface. |
| 95 | + */ |
| 96 | + public function next() {} |
| 97 | + |
| 98 | + /** |
| 99 | + * Rewind back to the first log entry. Part of the Iterator interface. |
| 100 | + */ |
| 101 | + public function rewind() {} |
| 102 | + |
| 103 | + /** |
| 104 | + * Check if the current position is valid. Part of the Iterator interface. |
| 105 | + * |
| 106 | + * @return bool |
| 107 | + */ |
| 108 | + public function valid() {} |
| 109 | + |
| 110 | + /** |
| 111 | + * Get the number of log entries contained in this log. This is always less |
| 112 | + * than or equal to the number returned by getEventCount(), which includes |
| 113 | + * overruns. |
| 114 | + * |
| 115 | + * @return int |
| 116 | + */ |
| 117 | + public function count() {} |
| 118 | + |
| 119 | + /** |
| 120 | + * Determine whether a log entry exists at the specified array offset. |
| 121 | + * Part of the ArrayAccess interface. |
| 122 | + * |
| 123 | + * @param int $offset |
| 124 | + * @return bool |
| 125 | + */ |
| 126 | + public function offsetExists($offset) {} |
| 127 | + |
| 128 | + /** |
| 129 | + * Get the ExcimerLogEntry object at the specified array offset. |
| 130 | + * |
| 131 | + * @param int $offset |
| 132 | + * @return ExcimerLogEntry|null |
| 133 | + */ |
| 134 | + public function offsetGet($offset) {} |
| 135 | + |
| 136 | + /** |
| 137 | + * This function is included for compliance with the ArrayAccess interface. |
| 138 | + * It raises a warning and does nothing. |
| 139 | + * |
| 140 | + * @param int $offset |
| 141 | + * @param mixed $value |
| 142 | + */ |
| 143 | + public function offsetSet($offset, $value) {} |
| 144 | + |
| 145 | + /** |
| 146 | + * This function is included for compliance with the ArrayAccess interface. |
| 147 | + * It raises a warning and does nothing. |
| 148 | + * |
| 149 | + * @param int $offset |
| 150 | + */ |
| 151 | + public function offsetUnset($offset) {} |
| 152 | +} |
0 commit comments