nytprof.disabled added
authorDobrica Pavlinusic <dpavlin@rot13.org>
Mon, 28 Jun 2010 14:41:06 +0000 (16:41 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Mon, 28 Jun 2010 14:41:06 +0000 (16:41 +0200)
We don't really want to profile generation of html from profile data :-)

lib/MojoFacets/Plugin/NYTProf.pm
lib/MojoFacets/Profile.pm

index 4bc2f5a..20424eb 100644 (file)
@@ -26,7 +26,10 @@ sub register {
                        DB::disable_profile();
                        return unless my $id = $c->stash('nytprof.id');
                        my $duration = Time::HiRes::gettimeofday() - $id;
-                       if ( $duration > $p ) {
+                       if ( $c->stash('nytprof.disabled') ) {
+                               warn "profile disabled";
+                               unlink $path;
+                       } elsif ( $duration > $p ) {
                                my $path = "/tmp/nytprof.$id";
                                my $new  = "/tmp/MojoFacets.profile.$id-$duration";
                                rename $path, $new;
index 689f49e..ecdd77e 100644 (file)
@@ -16,8 +16,11 @@ sub index {
        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";
+               if ( ! -e $dir ) {
+                       mkpath $dir unless -d $dir;
+                       system "nytprofhtml --file $path$profile --out $dir";
+                       $self->stash( 'nytprof.disabled' => 1 );
+               }
                $self->redirect_to("/profile/$profile/index.html");
        }