Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Profile multiple runs on the same script - document rules of aggregation/skipping #274

Closed
maxgalbu opened this issue Aug 8, 2019 · 3 comments

Comments

@maxgalbu
Copy link

maxgalbu commented Aug 8, 2019

With an always-running PHP (while(true)) script and profiler.enable set to return true to profile all runs, the xhgui-collector still doesn't collect all the runs. Is there any way to collect multiple runs for the same script? What are the rules to avoid aggregation/skipping of runs?

@maxgalbu maxgalbu changed the title Document all teh rules of aggregation Document all the rules of aggregation Aug 8, 2019
@maxgalbu maxgalbu changed the title Document all the rules of aggregation Profile multiple runs on the same script - document rules of aggregation/skipping Aug 8, 2019
@maxgalbu
Copy link
Author

maxgalbu commented Aug 8, 2019

Found it:

//THIS LINE
$data['_id'] = new \MongoId();

$data['profile'] = xhprof_disable();
$data['meta'] = array(
    'url' => $uri,
    'SERVER' => $_SERVER,
    'get' => $_GET,
    'env' => $_ENV,
    'simple_url' => \Xhgui_Util::simpleUrl($uri),
    'request_ts' => time(),
    'request_ts_micro' => time() * 1000,
    'request_date' => date('Y-m-d', time()),
);

try {
    $config = \Xhgui_Config::all();
    $saver = \Xhgui_Saver::factory($config);
    $saver->save($data);
} catch (\Exception $e) {
    error_log('xhgui - ' . $e->getMessage());
}

@glensc
Copy link
Contributor

glensc commented Sep 14, 2020

I had a very similar question:

@glensc
Copy link
Contributor

glensc commented Oct 22, 2020

https://github.com/perftools/php-profiler#advanced-usage:

/** @var \Xhgui\Profiler\Profiler $profiler */
// start profiling
$profiler->enable($flags, $options);

// run program
foo();

// stop profiler
$profiler_data = $profiler->disable();

// send $profiler_data to saver
$profiler->save($profiler_data);

@glensc glensc closed this as completed Oct 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants