AsyncMysqlClientStats::ioEventLoopMicrosAvg

Average loop time of the MySQL client event, in microseconds

Description

public function ioEventLoopMicrosAvg(): float

An event can include a connection, an error condition, a query, etc.

This returns an exponentially-smoothed average.

Return Values

  • float - A float representing the average for an event to happen on this MySQL client.

Examples

The following example describes how to get the average loop time of this SQL client's event handling (in this particular case, performing the connection) via AsyncMysqlClientStats::ioEventLoopMicrosAvg.

<?hh

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

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_loop_info(): Awaitable<float> {
  $pool = new \AsyncMysqlConnectionPool(array());
  $conn = await connect($pool);
  $loop = $conn->connectResult()->clientStats()->ioEventLoopMicrosAvg();
  $conn->close();
  return $loop;
}

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

run();
Output
float(2.3164994879863)