Skip to content

Commit

Permalink
Add execution time to Enable Tracy button tooltip.
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianbj committed Feb 11, 2024
1 parent 78d355b commit 4080f4d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions TracyDebugger.module.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static function getModuleInfo() {
'summary' => __('Tracy debugger from Nette with many PW specific custom tools.', __FILE__),
'author' => 'Adrian Jones',
'href' => 'https://processwire.com/talk/forum/58-tracy-debugger/',
'version' => '4.25.14',
'version' => '4.25.15',
'autoload' => 100000, // in PW 3.0.114+ higher numbers are loaded first - we want Tracy first
'singular' => true,
'requires' => 'ProcessWire>=2.7.2, PHP>=5.4.4',
Expand All @@ -46,6 +46,7 @@ public static function getModuleInfo() {
const COLOR_ALERT = '#cd1818';

protected $data = array();
protected $time;
protected $httpReferer;
protected $tracyEnabled = false;
protected $earlyExit = false;
Expand Down Expand Up @@ -333,6 +334,8 @@ public function __construct() {
*/
public function init() {

$this->time = $_SERVER['REQUEST_TIME_FLOAT'] ?? microtime(true);

if(class_exists('\Tracy\Debugger', false) && Debugger::isEnabled()) return;

// load Tracy files and our helper files
Expand Down Expand Up @@ -1890,6 +1893,8 @@ protected function addUserBar($event) {
*/
protected function addEnableButton($event) {

$execution_time_tooltip = "Execution Time: ".number_format((microtime(true) - $this->time) * 1000, 1, '.', "\u{202f}")." ms";

// DON'T add comments to injected code below because it breaks my simple minify() function
// if Tracy temporarily toggled disabled, add enable icon link
$enableButton = '
Expand All @@ -1916,7 +1921,7 @@ function enableTracy() {
location.reload();
}
</script>
<div id="TracyEnableButton" title="Enable Tracy" onclick="enableTracy()">
<div id="TracyEnableButton" uk-tooltip="title: Enable Tracy<br />'.$execution_time_tooltip.'" title="Enable Tracy&#10;'.$execution_time_tooltip.'" onclick="enableTracy()">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="16px" height="16.6px" viewBox="199.6 129.9 16 16.6" enable-background="new 199.6 129.9 16 16.6" xml:space="preserve">
<path fill="'.self::COLOR_NORMAL.'" d="M215.4,139.4c-0.1-0.1-0.3-0.2-0.4-0.2h-1v0c0-0.4-0.1-0.8-0.1-1.2c-0.1-0.7-0.4-1.4-0.8-2l1.5-1.5
Expand Down

0 comments on commit 4080f4d

Please sign in to comment.