AsyncMysqlClientStats::callbackDelayMicrosAvg

Average delay between when a callback is scheduled in the MySQL client and when it's actually ran, in microseconds.

Description

public function callbackDelayMicrosAvg(): float

Average delay between when a callback is scheduled in the MySQL client and when it's actually ran, in microseconds.

The callback can be from creating a connection, inducing an error condition, executing a query, etc.

This returns an exponentially-smoothed average.

Return Values

  • float - A float representing the average callback delay on this MySQL client.

Examples

The following example describes how to get the average delay time between when a callback is scheduled (in this case, performing the connection) and when the callback actual ran (in this case, when the connection was actually established) via AsyncMysqlClientStats::callbackDelayMicrosAvg.

<?hh

namespace Hack\UserDocumentation\API\Examples\AsyncMysql\CStats\CBackDelayMicro;

use \Hack\UserDocumentation\API\Examples\AsyncMysql\ConnectionInfo as CI;

async function connect(\AsyncMysqlConnectionPool $pool):
  Awaitable<\AsyncMysqlConnection> {
  return await $pool->connect(
    CI::$host,
    CI::$port,
    CI::$db,
    CI::$user,
    CI::$passwd
  );
}
async function get_delay(): Awaitable<float> {
  $pool = new \AsyncMysqlConnectionPool(array());
  $conn = await connect($pool);
  $delay = $conn->connectResult()->clientStats()->callbackDelayMicrosAvg();
  $conn->close();
  return $delay;
}

function run(): void {
  $d = \HH\Asio\join(get_delay());
  var_dump($d);
}

run();
Output
float(11.98046875)