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 {
--- /dev/null
+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
% if ( my $id = stash('nytprof.id') ) {
·
-<a href="<%= url_for( controller => 'profile', action => 'index', id => $id ) %>">profile</a>
+<a href="<%= url_for( controller => 'profile', action => 'index', id => 0 ) %>">profile</a>
% }
<span class=middle>
--- /dev/null
+% layout 'default';
+
+<ul>
+% foreach my $profile ( @$profiles ) {
+% my ( $t, $duration ) = split(/-/,$profile,2);
+<li><a target="<%= $profile %>" href="<%= url_for()->query( profile => $profile ) %>"><%= $t %></a> <%= $duration %>
+</li>
+% }
+</ul>
+
+<pre class=debug><%= dumper $profiles %></pre>