Skip to content

Commit

Permalink
profiling without error
Browse files Browse the repository at this point in the history
  • Loading branch information
jan.hajek committed Feb 4, 2017
1 parent b4391e5 commit b019cd7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
29 changes: 25 additions & 4 deletions src/Diagnostics/Panel/Profiling/Profiling.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,16 @@

class Profiling implements IBarPanel
{
/**
* @var bool
*/
private $enabled;

/**
* @var string[]
*/
private $errorMessages = [];

/**
* @param Request $request
* @param Session $session
Expand All @@ -23,12 +31,17 @@ public function __construct(Request $request, Session $session)
}
$this->enabled = $sessionSection['enabled'];

if ($this->enabled) {
tideways_enable(TIDEWAYS_FLAGS_NO_SPANS);
$tidewaysExists = function_exists('tideways_enable');
if (!$tidewaysExists) {
$this->errorMessages[] = 'tideways_enable not exists';
}

if ($this->enabled && $tidewaysExists) {
\tideways_enable(TIDEWAYS_FLAGS_NO_SPANS);

register_shutdown_function(
function () {
$data = tideways_disable();
$data = \tideways_disable();
file_put_contents(
sys_get_temp_dir() . "/" . uniqid() . ".run.xhprof",
serialize($data)
Expand All @@ -38,6 +51,9 @@ function () {
}
}

/**
* @return string
*/
public function getTab()
{
ob_start();
Expand All @@ -46,11 +62,17 @@ public function getTab()
return ob_get_clean();
}

/**
* @return string
*/
public function getId()
{
return __CLASS__;
}

/**
* @return string
*/
public function getPanel()
{
ob_start();
Expand All @@ -59,4 +81,3 @@ public function getPanel()
return ob_get_clean();
}
}

3 changes: 3 additions & 0 deletions src/Diagnostics/Panel/Profiling/templates/panel.phtml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<h1>Profiling</h1>
<div class="tracy-inner">
<?php if (count($this->errorMessages) > 0) { ?>
Errors: <?= implode(', ', $this->errorMessages) ?><br />
<?php } ?>
profiling <?= $this->enabled ? 'enabled' : 'disabled'?>

<form action="" method="post" class="form">
Expand Down

0 comments on commit b019cd7

Please sign in to comment.