/[VRac]/Session.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /Session.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 159 by dpavlin, Sun Aug 5 18:25:53 2007 UTC revision 186 by dpavlin, Sun Sep 30 19:50:30 2007 UTC
# Line 11  use File::Slurp; Line 11  use File::Slurp;
11  use POSIX qw/strftime/;  use POSIX qw/strftime/;
12    
13  use base qw/Class::Accessor/;  use base qw/Class::Accessor/;
14  __PACKAGE__->mk_accessors(qw(session_uuid));  __PACKAGE__->mk_accessors(qw(session_uuid session_path));
15    
16    
17  =head1 NAME  =head1 NAME
# Line 35  them. Line 35  them.
35    
36  =cut  =cut
37    
 my $path = 'session.pl';  
   
38  my $last_tick = 0;  my $last_tick = 0;
39    
40  my $t = 0;  my $t = 0;
# Line 48  sub record_session { Line 46  sub record_session {
46          my $name = shift || confess "need name";          my $name = shift || confess "need name";
47          my $value = shift || confess "need value";          my $value = shift || confess "need value";
48    
49            my $path = $self->session_path;
50    
51            if ( ! $path ) {
52                    $path = 'sess/current';
53                    $self->session_path( $path );
54                    if ( -e $path ) {
55                            warn "session appending to: $path\n";
56                    } else {
57                            warn "session creating: $path\n";
58                    }
59            }
60    
61          if ( @timeline ) {          if ( @timeline ) {
62                  warn "INFO: Aborting recorderd session\n";                  warn "INFO: Aborting recorderd session\n";
63                  @timeline = ();                  @timeline = ();
64                  $t = 0;                  $t = 0;
65                  $s = {};                  $s = {};
66                    $last_tick = 0;
67          }          }
68    
69          my $t = $self->app->ticks;          my $t = $self->app->ticks;
# Line 78  sub event { Line 89  sub event {
89          push @timeline, $t;          push @timeline, $t;
90          $s->{$t}->{$name} = $value;          $s->{$t}->{$name} = $value;
91    
92          warn "## created event($dt,$name,",dump($value),")\n";  #       warn "## created event($dt,$name,",dump($value),")\n";
93  }  }
94    
95  =head2 load_session  =head2 load_session
# Line 97  sub load_session { Line 108  sub load_session {
108          }          }
109    
110          eval read_file( $path );          eval read_file( $path );
111          warn "session = ",dump( $s );          warn "session = ",dump( $s ) if $self->debug;
112    
113          my ( $from, $to ) = @timeline[0,-1];          my ( $from, $to ) = @timeline[0,-1];
114          printf "loaded session %.2f-%.2fs with %d events\n", $from / 1000, $to / 1000, $#timeline + 1;          printf "loaded session %.2f-%.2fs with %d events\n", $from / 1000, $to / 1000, $#timeline + 1;

Legend:
Removed from v.159  
changed lines
  Added in v.186

  ViewVC Help
Powered by ViewVC 1.1.26