/[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

Contents of /trunk/bin/sack.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3 - (show annotations)
Sun Sep 20 18:55:34 2009 UTC (14 years, 7 months ago) by dpavlin
File MIME type: text/plain
File size: 1385 byte(s)
open out/* in vi with any of commands: vi \e out

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 bytes $path"
64 , $len < 10000 ? " \$out = $dump" : ' SAVED ONLY'
65 , "\n"
66 ;
67 write_file $path, $dump;
68 report "save $path";
69 }
70
71 }
72 }
73
74 run_views;
75
76 while ( 1 ) {
77
78 print "sack> ";
79 my $cmd = <STDIN>;
80
81 if ( $cmd =~ m{(vi|\\e|out)}i ) {
82 system "vi out/*";
83 } else {
84 run_views;
85 }
86
87 }
88

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26