forked from aterrien/forp-PHP-profiler
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathforp.php
More file actions
40 lines (37 loc) · 776 Bytes
/
Copy pathforp.php
File metadata and controls
40 lines (37 loc) · 776 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
$br = (php_sapi_name() == "cli")? "\n":"<br>\n";
$module = 'forp';
if(!extension_loaded($module)) {
dl($module . '.' . PHP_SHLIB_SUFFIX);
}
$functions = get_extension_funcs($module);
echo "Functions available in the test extension:". $br;
foreach($functions as $func) {
echo $func.$br;
}
echo $br;
// testing forp functions
echo '- Enable'.$br;
forp_start();
/**
* @ProfileGroup("fibo")
* @ProfileCaption("fibo of #1")
*/
function fibo( $x ) {
if ( $x <= 1) {
return $x;
} else {
return fibo($x - 1) + fibo($x - 2);
}
}
for( $i = 1; $i < 10; $i++) {
printf(
'fibo(%1$s) = %2$s'.$br,
$i, fibo($i)
);
}
echo '- Dump'.$br;
$dump = forp_dump();
print_r( $dump['stack'][0] );
echo '- Print'.$br;
forp_print();