From: gfx Date: Tue, 13 Oct 2009 05:40:19 +0000 (+0900) Subject: Improve he-profile.pl X-Git-Tag: 0.38~7 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMouse.git;a=commitdiff_plain;h=e35756639f8ad7fd92e617689afcd1c19d75ce5e Improve he-profile.pl --- diff --git a/author/he-profile.pl b/author/he-profile.pl index dbab673..863b515 100644 --- a/author/he-profile.pl +++ b/author/he-profile.pl @@ -3,21 +3,25 @@ use strict; -my $script = 'bench/foo.pl'; +my $script = 'author/use-he.pl'; my $branch = do{ - open my $in, '.git/HEAD' or die "Cannot open .git/HEAD: $!"; - my $s = scalar <$in>; - chomp $s; - $s =~ s{^ref: \s+ refs/heads/}{}xms; - $s =~ s{/}{_}xmsg; - $s; + if(open my $in, '.git/HEAD'){ + my $s = scalar <$in>; + chomp $s; + $s =~ s{^ref: \s+ refs/heads/}{}xms; + $s =~ s{/}{_}xmsg; + $s; + } + else{ + require 'lib/Mouse/Spec.pm'; + Mouse::Spec->VERSION; + } }; print "Profiling $branch ...\n"; -my @cmd = ($^X, '-Iblib/lib', '-Iblib/arch', '-d:NYTProf', '-e', - 'require HTTP::Engine; require HTTP::Engine::Interface::CGI'); +my @cmd = ($^X, '-Iblib/lib', '-Iblib/arch', '-d:NYTProf', $script); print "> @cmd\n"; system(@cmd) == 0 or die "Cannot profile"; diff --git a/author/use-he.pl b/author/use-he.pl new file mode 100644 index 0000000..1aa3b48 --- /dev/null +++ b/author/use-he.pl @@ -0,0 +1,19 @@ +#!perl -w + +use strict; +use HTTP::Engine; + +my $engine = HTTP::Engine->new( + interface => { + module => 'CGI', + request_handler => \&handle_request, + }, +); + +$engine->run(); + +sub handle_request{ + my($request) = @_; + + return HTTP::Engine::Response->new(body => "Hello, world!\n"); +}