定制 endeveit/btp-api 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

endeveit/btp-api

Composer 安装命令:

composer require endeveit/btp-api

包简介

API library for BTP daemon.

README 文档

README

API library for BTP daemon.

BTP daemon is performance analysis daemon from developers of Mamba portal.

This library is PHP 5.3 port of official old-style library.

Example of usage

Let's say you have a code like this:

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:

use Btp\Api\Connection;

$btpConnection = new Connection();

Now we can work with counters.

There is two ways to use them:

  • 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;
}

统计信息

  • 总下载量: 6.43k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2012-11-22