dev-master
9999999-dev http://github.com/endeveit/btp-apiAPI library for BTP daemon.
MIT
The Requires
- php >=5.3
api mamba btp
Wallogit.com
2017 © Pedro Peláez
API library for BTP daemon.
API library for BTP daemon., (*1)
BTP daemon is performance analysis daemon from developers of Mamba portal., (*2)
This library is PHP 5.3 port of official old-style library., (*3)
Let's say you have a code like this:, (*4)
function getSomethingFromDatabase()
{
$data = Database::getConnection()->query('SELECT * FROM `table` WHERE `id` IN (1, 2)');
$result = array();
foreach ($data as $row) {
$result[] = $row[];
}
return $result;
}
First we should instantiate new Btp\Api\Connection object:, (*5)
use Btp\Api\Connection; $btpConnection = new Connection();
Now we can work with counters., (*6)
There is two ways to use them:, (*7)
// Will be measured only time of Database::getConnection()->query()
function getSomethingFromDatabase(Connection $btpConnection)
{
$counter = $btpConnection->getCounter(array(
'srv' => 'db7',
'service' => 'mysql',
'op' => 'select',
));
$data = Database::getConnection()->query('SELECT * FROM `table` WHERE `id` IN (1, 2)');
$counter->stop();
$result = array();
foreach ($data as $row) {
$result[] = $row[];
}
return $result;
}
// Will be measured all operations from time of counter initialization till the function
// return statement (when the Btp\Api\Counter object's destructor will be called)
function getSomethingFromDatabase(Connection $btpConnection)
{
$counter = $btpConnection->getCounter(array(
'srv' => 'db7',
'service' => 'mysql',
'op' => 'select',
));
$data = Database::getConnection()->query('SELECT * FROM `table` WHERE `id` IN (1, 2)');
$result = array();
foreach ($data as $row) {
$result[] = $row[];
}
return $result;
}
API library for BTP daemon.
MIT
api mamba btp