From: Dobrica Pavlinusic Date: Mon, 28 Jun 2010 14:32:01 +0000 (+0200) Subject: generate profile output X-Git-Url: http://git.rot13.org/?p=MojoFacets.git;a=commitdiff_plain;h=4c26ead649e3118c016577279ed1fec491cca453 generate profile output --- diff --git a/lib/MojoFacets/Plugin/NYTProf.pm b/lib/MojoFacets/Plugin/NYTProf.pm index 7cf729a..4bc2f5a 100644 --- a/lib/MojoFacets/Plugin/NYTProf.pm +++ b/lib/MojoFacets/Plugin/NYTProf.pm @@ -28,7 +28,7 @@ sub register { my $duration = Time::HiRes::gettimeofday() - $id; if ( $duration > $p ) { my $path = "/tmp/nytprof.$id"; - my $new = "/tmp/MojoFacets.profile-$id-$duration"; + my $new = "/tmp/MojoFacets.profile.$id-$duration"; rename $path, $new; warn "profile $new $duration ", -s $new, " bytes\n"; } else { diff --git a/lib/MojoFacets/Profile.pm b/lib/MojoFacets/Profile.pm new file mode 100644 index 0000000..689f49e --- /dev/null +++ b/lib/MojoFacets/Profile.pm @@ -0,0 +1,30 @@ +package MojoFacets::Profile; + +use strict; +use warnings; + +use base 'Mojolicious::Controller'; + +use Data::Dump qw(dump); +use File::Path; + +sub index { + my $self = shift; + + my $path = '/tmp/MojoFacets.profile.'; + + if ( my $profile = $self->param('profile') ) { +warn "XXX profile $profile\n"; + my $dir = $self->app->home->rel_dir('public') . "/profile/$profile"; + mkpath $dir unless -d $dir; + system "nytprofhtml --file $path$profile --out $dir"; + $self->redirect_to("/profile/$profile/index.html"); + } + + + $self->render( + profiles => [ map { s/^\Q$path\E//; $_ } glob "$path*" ], + ); +} + +1 diff --git a/templates/admin.html.ep b/templates/admin.html.ep index 5d01f8e..d98a64c 100644 --- a/templates/admin.html.ep +++ b/templates/admin.html.ep @@ -21,7 +21,7 @@ items: % if ( my $id = stash('nytprof.id') ) { · -profile +profile % } diff --git a/templates/profile/index.html.ep b/templates/profile/index.html.ep new file mode 100644 index 0000000..fea1ecb --- /dev/null +++ b/templates/profile/index.html.ep @@ -0,0 +1,11 @@ +% layout 'default'; + + + +
<%= dumper $profiles %>