2017 © Pedro Peláez
 

library btp-api

API library for BTP daemon.

image

endeveit/btp-api

API library for BTP daemon.

  • Tuesday, April 26, 2016
  • by endeveit
  • Repository
  • 1 Watchers
  • 2 Stars
  • 5,910 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 1 % Grown

The README.md

BTP API

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)

Example of usage

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)

  • The explicit stop of counter.
// 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;
}
  • Counter stop in destructor.
// 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;
}

The Versions

26/04 2016

dev-master

9999999-dev http://github.com/endeveit/btp-api

API library for BTP daemon.

  Sources   Download

MIT

The Requires

  • php >=5.3

 

api mamba btp