<?php

// Helper function.
if (! function_exists('timer')) {
    function timer($expression)
    {
        $start = microtime(true);

        if ($expression instanceof Closure) {
            $expression();
        } else {
            eval(rtrim($expression, ';') . ';');
        }

        return microtime(true) - $start . " Seconds";
    }
}

// Query builder macro.
Illuminate\Database\Eloquent\Builder::macro('timer', function() {
    $start = microtime(true);

    $this->get();

    return microtime(true) - $start . " Seconds";
});