Commit | Line | Data |
384fb396 |
1 | #!/usr/bin/perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
6 | use lib 'lib'; |
7 | |
8 | use File::Temp; |
9 | |
10 | use Text::Tradition; |
11 | use Text::Tradition::Directory; |
12 | |
13 | ## We're loading the besoin data, and dumping the backend db rows into |
14 | ## a .sql file for load testing (testing of data loading, not the |
15 | ## other sort) |
16 | my $sql = 't/data/speed_test_load.sql'; |
17 | my $uuid = 'load-test'; |
18 | |
19 | print "Loading t/data/besoin.xml and storing it in $sql ...\n"; |
20 | |
21 | ## Load tradition data: |
22 | my $tradition = Text::Tradition->new( |
23 | 'input' => 'Self', |
24 | 'file' => "t/data/besoin.xml" |
25 | ); |
26 | $tradition->add_stemma(dotfile => "t/data/besoin.dot"); |
27 | |
28 | ## save to db: |
29 | my $fh = File::Temp->new(); |
30 | my $file = $fh->filename; |
31 | $fh->close; |
32 | |
33 | my $dsn = "dbi:SQLite:$file"; |
34 | my $dir = Text::Tradition::Directory->new( |
35 | dsn => $dsn, |
36 | extra_args => { create => 1 }, |
37 | ); |
38 | my $scope = $dir->new_scope; |
39 | $dir->store($uuid, $tradition); |
40 | |
41 | ## out to SQL file: |
42 | `sqlite3 $file ".dump" > $sql`; |
43 | |
44 | print "$sql updated,\n"; |