AsyncMysqlClientStats::ioEventLoopMicrosAvg

Average loop time of the MySQL client event, in microseconds

public function ioEventLoopMicrosAvg(): float;

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

This returns an exponentially-smoothed average.

Returns

  • 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.

require __DIR__.'/../../__includes/async_mysql_connect.inc.php';

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(darray[]);
  $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)