timing() public static method

Log timing information
public static timing ( string $stat, float $time, float $sampleRate = 1, array $tags = null )
$stat string The metric to in log timing info for.
$time float The elapsed time (ms) to log
$sampleRate float the rate (0-1) for sampling.
$tags array Key Value array of Tag => Value, or single tag as string
function runFunction()
{
    global $apiKey;
    global $appKey;
    $startTime = microtime(true);
    $testArray = array();
    for ($i = 0; $i < rand(1, 1000000000); $i++) {
        $testArray[$i] = $i;
        // Simulate an event at every 1000000th element
        if ($i % 1000000 == 0) {
            echo "Event simulated.\n";
            Datadogstatsd::event('A thing broke!', array('alert_type' => 'error', 'aggregation_key' => 'test_aggr'));
            Datadogstatsd::event('Now it is fixed.', array('alert_type' => 'success', 'aggregation_key' => 'test_aggr'));
        }
    }
    unset($testArray);
    Datadogstatsd::timing('test.data.point', microtime(true) - $startTime, 1, array('tagname' => 'php_example_tag_2'));
}
 /**
  * Log timing information
  *
  * @param string $stat The metric to in log timing info for.
  * @param float $time The ellapsed time (ms) to log
  * @param float|1 $sampleRate the rate (0-1) for sampling.
  * @param array $tags
  **/
 public function timing($key, $value, $sampleRate = 1, $tags = array())
 {
     \Datadogstatsd::timing($key, $value, $sampleRate, $tags);
 }