Simple-Timer

 view release on metacpan or  search on metacpan

lib/Simple/Timer.pm  view on Meta::CPAN

use strict;
use warnings;
no strict 'refs';
no warnings 'once';

use Time::HiRes;
use Time::Stopwatch;

tie our($TIMER), 'Time::Stopwatch';

sub timer(&) {
    local $TIMER = 0;
    shift->();
    say $TIMER;
}

sub import {
    my $class = shift;
    my $caller = caller;

    # this does not work, caller's $TIMER is not tied



( run in 0.217 second using v1.01-cache-2.11-cpan-49f99fa48dc )