Skip to content

Instantly share code, notes, and snippets.

@beberlei
Last active August 29, 2015 14:04
Show Gist options
  • Save beberlei/231fa0f97e868d2ea97e to your computer and use it in GitHub Desktop.
Save beberlei/231fa0f97e868d2ea97e to your computer and use it in GitHub Desktop.
<?php
$options = array(
'argument_functions' => array(
'file_get_contents',
'curl_exec',
'fgets',
'fputs',
'fread',
'fgetcsv',
'stream_get_contents',
'PDOStatement::execute',
'PDO::query'
)
);
xhprof_enable(0, $options);
function fetch($url)
{
return file_get_contents($url);
}
function fetch_curl($url)
{
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
return curl_exec($ch);
}
fetch('http://qafoo.com');
fetch('http://php.net');
fetch_curl('http://qafoo.com');
fetch_curl('http://php.net');
$fh = fopen(__FILE__, 'r');
while ($line = fgets($fh, 4096)) {
fputs($fh, "foo");
}
fclose($fh);
$fh = fopen(__FILE__, 'r');
stripos(stream_get_contents($fh), 1);
$pdo = new PDO('sqlite:memory:', 'root', '');
$stmt = $pdo->prepare("SELECT 1");
$stmt->execute();
$stmt = $pdo->query("SELECT 1");
$stmt->execute();
var_dump(xhprof_disable());
array(22) {
["fetch==>file_get_contents#http://qafoo.com"]=>
array(2) {
["ct"]=>
int(1)
["wt"]=>
int(166431)
}
["main()==>fetch"]=>
array(2) {
["ct"]=>
int(2)
["wt"]=>
int(925031)
}
["fetch==>file_get_contents#http://php.net"]=>
array(2) {
["ct"]=>
int(1)
["wt"]=>
int(758525)
}
["fetch_curl==>curl_init"]=>
array(2) {
["ct"]=>
int(2)
["wt"]=>
int(103)
}
["fetch_curl==>curl_setopt"]=>
array(2) {
["ct"]=>
int(2)
["wt"]=>
int(17)
}
["fetch_curl==>curl_exec#http://qafoo.com"]=>
array(2) {
["ct"]=>
int(1)
["wt"]=>
int(67363)
}
["main()==>fetch_curl"]=>
array(2) {
["ct"]=>
int(2)
["wt"]=>
int(819680)
}
["fetch_curl==>curl_exec#http://php.net"]=>
array(2) {
["ct"]=>
int(1)
["wt"]=>
int(751951)
}
["main()==>str_repeat"]=>
array(2) {
["ct"]=>
int(1)
["wt"]=>
int(18)
}
["main()==>strlen"]=>
array(2) {
["ct"]=>
int(1)
["wt"]=>
int(2)
}
["main()==>fopen"]=>
array(2) {
["ct"]=>
int(2)
["wt"]=>
int(120)
}
["main()==>fgets#/home/benny/code/php/workspace/xhprof/examples/argument_functions.php"]=>
array(2) {
["ct"]=>
int(45)
["wt"]=>
int(253)
}
["main()==>fputs#/home/benny/code/php/workspace/xhprof/examples/argument_functions.php"]=>
array(2) {
["ct"]=>
int(44)
["wt"]=>
int(139)
}
["main()==>fclose"]=>
array(2) {
["ct"]=>
int(1)
["wt"]=>
int(12)
}
["main()==>stream_get_contents#/home/benny/code/php/workspace/xhprof/examples/argument_functions.php"]=>
array(2) {
["ct"]=>
int(1)
["wt"]=>
int(23)
}
["main()==>stripos"]=>
array(2) {
["ct"]=>
int(1)
["wt"]=>
int(20)
}
["main()==>PDO::__construct"]=>
array(2) {
["ct"]=>
int(1)
["wt"]=>
int(19183)
}
["main()==>PDO::prepare"]=>
array(2) {
["ct"]=>
int(1)
["wt"]=>
int(92)
}
["main()==>PDOStatement::execute#SELECT 1"]=>
array(2) {
["ct"]=>
int(2)
["wt"]=>
int(20)
}
["main()==>PDO::query#SELECT 1"]=>
array(2) {
["ct"]=>
int(1)
["wt"]=>
int(19)
}
["main()==>xhprof_disable"]=>
array(2) {
["ct"]=>
int(1)
["wt"]=>
int(0)
}
["main()"]=>
array(2) {
["ct"]=>
int(1)
["wt"]=>
int(1765651)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment