[Bast-commits] r3851 - trunk/Devel-REPL/lib/Devel/REPL/Plugin

Sartak at dev.catalyst.perl.org Sartak at dev.catalyst.perl.org
Sat Nov 3 00:23:56 GMT 2007


Author: Sartak
Date: 2007-11-03 00:23:56 +0000 (Sat, 03 Nov 2007)
New Revision: 3851

Added:
   trunk/Devel-REPL/lib/Devel/REPL/Plugin/Timing.pm
Log:
Add a Timing plugin to report how long each eval takes
This is probably going to be better served as a command itself


Added: trunk/Devel-REPL/lib/Devel/REPL/Plugin/Timing.pm
===================================================================
--- trunk/Devel-REPL/lib/Devel/REPL/Plugin/Timing.pm	                        (rev 0)
+++ trunk/Devel-REPL/lib/Devel/REPL/Plugin/Timing.pm	2007-11-03 00:23:56 UTC (rev 3851)
@@ -0,0 +1,26 @@
+package Devel::REPL::Plugin::Timing;
+
+use Moose::Role;
+use Time::HiRes 'time';
+use namespace::clean -except => [ 'meta' ];
+
+around 'eval' => sub {
+    my $orig = shift;
+    my ($self, $line) = @_;
+
+    my @ret;
+    my $start = time;
+
+    if (wantarray) {
+        @ret = $self->$orig($line);
+    }
+    else {
+        $ret[0] = $self->$orig($line);
+    }
+
+    $self->print("Took " . (time - $start) . " seconds.\n");
+    return @ret;
+};
+
+1;
+




More information about the Bast-commits mailing list