/[Sack]/trunk/bin/sack.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /trunk/bin/sack.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (hide annotations)
Sun Sep 20 18:42:07 2009 UTC (14 years, 8 months ago) by dpavlin
File MIME type: text/plain
File size: 1287 byte(s)
Sack - in-memory interactive object database in pure perl

1 dpavlin 1 #!/usr/bin/perl
2    
3     use warnings;
4     use strict;
5    
6     use Time::HiRes qw(time);
7     use Data::Dump qw(dump);
8     use File::Slurp;
9    
10     my $t = time;
11    
12    
13     use lib '/srv/webpac2/lib/';
14     use WebPAC::Input::ISI;
15     my $input = WebPAC::Input::ISI->new(
16     path => '/data/isi/full.txt',
17     limit => shift @ARGV || 1000,
18     );
19    
20    
21     sub report {
22     my $description = shift;
23     my $dt = time - $t;
24     printf "%s in %1.4fs %.2f/s\n", $description, $dt, $input->size / $dt;
25     }
26    
27    
28     report $input->size . ' records loaded';
29    
30     mkdir 'out' unless -e 'out';
31    
32     sub run_views {
33     my @views = glob 'views/*.pl';
34     warn "# views ", dump @views;
35    
36     foreach my $view ( @views ) {
37    
38     my ( $nr, $package ) = ( $1, $2 )
39     if $view =~ m{/(\d+)\.([^/]+(\.pl)?$)};
40    
41     my $out;
42    
43     next if system("perl -c $view") != 0;
44    
45     my $code = read_file $view;
46     warn $code;
47    
48     $t = time;
49    
50     foreach my $pos ( 1 .. $input->size ) {
51     my $rec = $input->fetch_rec($pos);
52    
53     eval $code;
54     die "ERROR [$pos] $@" if $@;
55     };
56    
57     report $view;
58    
59     if ( defined $out ) {
60     my $dump = dump $out;
61     my $len = length $dump;
62     my $path = "out/$nr.$package";
63     print "# $view [$len] $path"
64     , $len < 10000 ? " \$out = $dump" : ''
65     , "\n"
66     ;
67     write_file $path, $dump;
68     report "save $path";
69     }
70    
71     }
72     }
73    
74     while ( 1 ) {
75     run_views;
76    
77     print "sack> ";
78     my $cmd = <STDIN>;
79    
80     }
81    

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26