From: Jess Robinson Date: Tue, 22 May 2012 09:48:54 +0000 (+0000) Subject: Script to update load testing file X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=384fb3969e2dfa256dd6311be6e877d5486750bd;p=scpubgit%2Fstemmatology.git Script to update load testing file (used to create sql if we get a new set of testing data) --- diff --git a/t/bin/make-load-test.pl b/t/bin/make-load-test.pl new file mode 100644 index 0000000..3f7d9d6 --- /dev/null +++ b/t/bin/make-load-test.pl @@ -0,0 +1,44 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use lib 'lib'; + +use File::Temp; + +use Text::Tradition; +use Text::Tradition::Directory; + +## We're loading the besoin data, and dumping the backend db rows into +## a .sql file for load testing (testing of data loading, not the +## other sort) +my $sql = 't/data/speed_test_load.sql'; +my $uuid = 'load-test'; + +print "Loading t/data/besoin.xml and storing it in $sql ...\n"; + +## Load tradition data: +my $tradition = Text::Tradition->new( + 'input' => 'Self', + 'file' => "t/data/besoin.xml" +); +$tradition->add_stemma(dotfile => "t/data/besoin.dot"); + +## save to db: +my $fh = File::Temp->new(); +my $file = $fh->filename; +$fh->close; + +my $dsn = "dbi:SQLite:$file"; +my $dir = Text::Tradition::Directory->new( + dsn => $dsn, + extra_args => { create => 1 }, +); +my $scope = $dir->new_scope; +$dir->store($uuid, $tradition); + +## out to SQL file: +`sqlite3 $file ".dump" > $sql`; + +print "$sql updated,\n";