From 6eb47e6a3dab35df4fa91705d10c1f9fd7396214 Mon Sep 17 00:00:00 2001 From: dukeleto Date: Mon, 31 Aug 2009 06:35:38 +0000 Subject: [PATCH] [tools] Add timing information to parrot_shell.pl git-svn-id: https://svn.parrot.org/parrot/trunk@40886 d31e2699-5ff4-0310-a27c-f18f2fbe73fe --- tools/dev/parrot_shell.pl | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/dev/parrot_shell.pl b/tools/dev/parrot_shell.pl index 85690bf2d5..b54bfef60f 100644 --- a/tools/dev/parrot_shell.pl +++ b/tools/dev/parrot_shell.pl @@ -12,6 +12,7 @@ use IO::File (); use File::Spec; use Parrot::Config; use File::Temp qw/ tempfile /; +use Benchmark qw/timeit timestr :hireswallclock/; =head1 NAME @@ -124,17 +125,18 @@ sub eval_snippet { 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 { -- 2.11.4.GIT