/[Sack]/trunk/lib/Sack/View.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 /trunk/lib/Sack/View.pm

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

revision 92 by dpavlin, Sat Oct 3 21:09:51 2009 UTC revision 93 by dpavlin, Sat Oct 3 21:43:34 2009 UTC
# Line 8  use File::Slurp; Line 8  use File::Slurp;
8  use Carp qw(confess);  use Carp qw(confess);
9  use Data::Dump qw(dump);  use Data::Dump qw(dump);
10  use Storable;  use Storable;
11    use Time::HiRes qw(time);
12    
13    
14  sub new {  sub new {
# Line 39  sub new { Line 40  sub new {
40          while ( 1 ) {          while ( 1 ) {
41    
42                  my $data = Storable::fd_retrieve( $client );                  my $data = Storable::fd_retrieve( $client );
43                  warn "[$port] <<<< ", dump keys %$data;                  warn "[$port] <<<< ", dump( $data );
44    
45                  my $result;                  my $result;
46    
# Line 62  sub new { Line 63  sub new {
63    
64  }  }
65    
66    
67  our $rec;  our $rec;
68  our $out;  our $out;
69    
# Line 71  sub view { Line 73  sub view {
73          undef $out;          undef $out;
74    
75          my $affected = 0;          my $affected = 0;
76          $self->report_start;          my $start_t = time;
77    
78          my $coderef = eval "sub { $code }";          my $coderef = eval "sub { $code }";
79          if ( $@ ) {          if ( $@ ) {
# Line 81  sub view { Line 83  sub view {
83    
84    
85          foreach my $pos ( 0 .. $#{ $self->{data} } ) {          foreach my $pos ( 0 .. $#{ $self->{data} } ) {
86                  $rec = $self->{data}->{$pos};                  $rec = $self->{data}->[$pos];
87                  if ( ! $rec ) {                  if ( ! $rec ) {
88                          print STDERR "END @ $pos";                          print STDERR "END @ $pos";
89                          last;                          last;
# Line 99  sub view { Line 101  sub view {
101                  $pos % 1000  == 0 ? print STDERR "."  : 0 ;                  $pos % 1000  == 0 ? print STDERR "."  : 0 ;
102          };          };
103    
104          $self->report( "$affected affected" );          my $dt = time - $start_t;
105            my $report = [ $self->{port}, $affected, $dt, scalar $self->{data} / $dt ];
106            warn sprintf "[%d] %d affected in %1.4fs %.2f/s\n", @$report;
107    
108            warn "out ", dump( $out );
109    
110            return $out;
111  }  }
112    
113  1;  1;

Legend:
Removed from v.92  
changed lines
  Added in v.93

  ViewVC Help
Powered by ViewVC 1.1.26