Support for stacked profiler analysis

This commit is contained in:
Michael 2021-07-27 04:57:29 +00:00
parent 3cef3ab107
commit c89533a70b
17 changed files with 763 additions and 611 deletions

View file

@ -236,9 +236,9 @@ class Addon
return $info;
}
$stamp1 = microtime(true);
DI::profiler()->startRecording('file');
$f = file_get_contents("addon/$addon/$addon.php");
DI::profiler()->saveTimestamp($stamp1, "file");
DI::profiler()->stopRecording();
$r = preg_match("|/\*.*\*/|msU", $f, $m);

View file

@ -52,11 +52,11 @@ class ProfilerCache implements ICache, IMemoryCache
*/
public function getAllKeys($prefix = null)
{
$time = microtime(true);
$this->profiler->startRecording('cache');
$return = $this->cache->getAllKeys($prefix);
$this->profiler->saveTimestamp($time, 'cache');
$this->profiler->stopRecording();
return $return;
}
@ -66,11 +66,11 @@ class ProfilerCache implements ICache, IMemoryCache
*/
public function get($key)
{
$time = microtime(true);
$this->profiler->startRecording('cache');
$return = $this->cache->get($key);
$this->profiler->saveTimestamp($time, 'cache');
$this->profiler->stopRecording();
return $return;
}
@ -80,11 +80,11 @@ class ProfilerCache implements ICache, IMemoryCache
*/
public function set($key, $value, $ttl = Duration::FIVE_MINUTES)
{
$time = microtime(true);
$this->profiler->startRecording('cache');
$return = $this->cache->set($key, $value, $ttl);
$this->profiler->saveTimestamp($time, 'cache');
$this->profiler->stopRecording();
return $return;
}
@ -94,11 +94,11 @@ class ProfilerCache implements ICache, IMemoryCache
*/
public function delete($key)
{
$time = microtime(true);
$this->profiler->startRecording('cache');
$return = $this->cache->delete($key);
$this->profiler->saveTimestamp($time, 'cache');
$this->profiler->stopRecording();
return $return;
}
@ -108,11 +108,11 @@ class ProfilerCache implements ICache, IMemoryCache
*/
public function clear($outdated = true)
{
$time = microtime(true);
$this->profiler->startRecording('cache');
$return = $this->cache->clear($outdated);
$this->profiler->saveTimestamp($time, 'cache');
$this->profiler->stopRecording();
return $return;
}
@ -123,11 +123,11 @@ class ProfilerCache implements ICache, IMemoryCache
public function add($key, $value, $ttl = Duration::FIVE_MINUTES)
{
if ($this->cache instanceof IMemoryCache) {
$time = microtime(true);
$this->profiler->startRecording('cache');
$return = $this->cache->add($key, $value, $ttl);
$this->profiler->saveTimestamp($time, 'cache');
$this->profiler->stopRecording();
return $return;
} else {
@ -141,11 +141,11 @@ class ProfilerCache implements ICache, IMemoryCache
public function compareSet($key, $oldValue, $newValue, $ttl = Duration::FIVE_MINUTES)
{
if ($this->cache instanceof IMemoryCache) {
$time = microtime(true);
$this->profiler->startRecording('cache');
$return = $this->cache->compareSet($key, $oldValue, $newValue, $ttl);
$this->profiler->saveTimestamp($time, 'cache');
$this->profiler->stopRecording();
return $return;
} else {
@ -159,11 +159,11 @@ class ProfilerCache implements ICache, IMemoryCache
public function compareDelete($key, $value)
{
if ($this->cache instanceof IMemoryCache) {
$time = microtime(true);
$this->profiler->startRecording('cache');
$return = $this->cache->compareDelete($key, $value);
$this->profiler->saveTimestamp($time, 'cache');
$this->profiler->stopRecording();
return $return;
} else {

View file

@ -73,7 +73,7 @@ class Renderer
*/
public static function replaceMacros(string $template, array $vars = [])
{
$stamp1 = microtime(true);
DI::profiler()->startRecording('rendering');
// pass $baseurl to all templates if it isn't set
$vars = array_merge(['$baseurl' => DI::baseUrl()->get(), '$APP' => DI::app()], $vars);
@ -90,7 +90,7 @@ class Renderer
throw new InternalServerErrorException($message);
}
DI::profiler()->saveTimestamp($stamp1, "rendering");
DI::profiler()->stopRecording();
return $output;
}
@ -106,7 +106,7 @@ class Renderer
*/
public static function getMarkupTemplate($file, $subDir = '')
{
$stamp1 = microtime(true);
DI::profiler()->startRecording('file');
$t = self::getTemplateEngine();
try {
@ -119,7 +119,7 @@ class Renderer
throw new InternalServerErrorException($message);
}
DI::profiler()->saveTimestamp($stamp1, "file");
DI::profiler()->stopRecording();
return $template;
}

View file

@ -88,9 +88,9 @@ class Theme
return $info;
}
$stamp1 = microtime(true);
DI::profiler()->startRecording('file');
$theme_file = file_get_contents("view/theme/$theme/theme.php");
DI::profiler()->saveTimestamp($stamp1, "file");
DI::profiler()->stopRecording();
$result = preg_match("|/\*.*\*/|msU", $theme_file, $matches);