-
Notifications
You must be signed in to change notification settings - Fork 5
/
sample.php
30 lines (23 loc) · 1.04 KB
/
sample.php
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
<?php
/**
* A sample php file demoing use of the pinba php extension: simple usage
*/
// Start time measurement _asap_: before autoloading even kicks in
$startTime = microtime(true);
include('vendor/autoload.php');
// This is optional - if omitted, time measurement will start during class autoloading in the line above, and be just
// a little less accurate
use \PinbaPhp\Polyfill\PinbaFunctions as pinba;
pinba::init($startTime);
// Do some stuff here ...
// Measure some operation with a specific timer: example
$connection = mysqli_connect('...');
$t = pinba_timer_start(array("group"=>"mysql", "server"=>"db1", "operation"=>"select"));
$result = mysqli_query("SELECT ... FROM ... WHERE ...", $connection);
pinba_timer_stop($t);
// Do some more stuff
// ...
// Finally: that's all folks!
// Memory usage, execution time, timers info etc. will be automatically collected and at the end of the execution
// of this page will be flushed to the Pinba server via an udp network packet, provided you have set `pinba.enabled` and
// `pinba.server` in php.ini.