[svn:parrot] r40886 - trunk/tools/dev

dukeleto at svn.parrot.org dukeleto at svn.parrot.org
Mon Aug 31 06:35:41 UTC 2009


Author: dukeleto
Date: Mon Aug 31 06:35:38 2009
New Revision: 40886
URL: https://trac.parrot.org/parrot/changeset/40886

Log:
[tools] Add timing information to parrot_shell.pl

Modified:
   trunk/tools/dev/parrot_shell.pl

Modified: trunk/tools/dev/parrot_shell.pl
==============================================================================
--- trunk/tools/dev/parrot_shell.pl	Mon Aug 31 02:32:43 2009	(r40885)
+++ trunk/tools/dev/parrot_shell.pl	Mon Aug 31 06:35:38 2009	(r40886)
@@ -12,6 +12,7 @@
 use File::Spec;
 use Parrot::Config;
 use File::Temp qw/ tempfile /;
+use Benchmark qw/timeit timestr :hireswallclock/;
 
 =head1 NAME
 
@@ -124,17 +125,18 @@
     my $stdoutfn = get_tempfile();
     my $f        = IO::File->new(">$codefn");
 
-    $f->print(normalize_snippet($snippet));
+    $f->print(normalize_snippet($snippet || ''));
     $f->close();
 
-    system("$parrot $codefn >$stdoutfn 2>&1");
+    my $time = timestr(timeit(1, sub { system("$parrot $codefn >$stdoutfn 2>&1") } ));
+    $time =~ s/\(.*//g;
 
     handle_errors($?) if $?;
 
     $f = IO::File->new($stdoutfn);
 
     my $output = join( '', <$f> );
-    return "Output:\n$output";
+    return "Time: $time\nOutput:\n$output";
 }
 
 sub handle_errors {


More information about the parrot-commits mailing list