blob: f7d0cb04e665d49764328eda40f2b6687b354af7 [file] [log] [blame]
Akron6e886f72020-02-19 07:42:32 +01001#!/usr/bin/env perl
2use strict;
3use warnings;
4use Dumbbench;
5use File::Basename 'dirname';
6use File::Spec::Functions qw/catfile catdir rel2abs/;
7use File::Temp ':POSIX';
8use FindBin;
9use Getopt::Long;
10
11BEGIN {
12 unshift @INC, "$FindBin::Bin/../lib";
13};
14
15my $columns = 0;
16my $no_header = 0;
17GetOptions(
18 'columns|c' => \$columns,
19 'no-header|n' => \$no_header,
20 'help|h' => sub {
21 print "--columns|-c Print instances in columns\n";
22 print "--no-header|-n Dismiss benchmark names\n";
23 print "--help|-h Print this page\n\n";
24 exit(0);
25 }
26);
27
28our $SCRIPT_NAME = 'korapxml2krill';
29
30my $f = dirname(__FILE__);
31my $script = rel2abs(catfile($f, '..', 'script', $SCRIPT_NAME));
32
33
34# begin instance 1 setup
35# Load example file
36my $input = rel2abs(catdir($f, '..', 't', 'annotation', 'corpus', 'doc', '0001'));
37my $output = tmpnam();
38my $cache = tmpnam();
39# end instance 1
40
41# Create a new benchmark object
42my $bench = Dumbbench->new(
43 verbosity => 0
44);
45
46# Add benchmark instances
47$bench->add_instances(
48 Dumbbench::Instance::PerlSub->new(
49 name => 'ExampleRun 1',
50 code => sub {
51 my $cmd = join(
52 ' ',
53 'perl', $script,
54 '--input' => $input,
55 '--output' => $output,
56 '--cache' => $cache,
57 '-k' => '0.03',
58 '-t' => 'OpenNLP#Tokens',
59 '-l' => 'ERROR',
60 '>' => '/dev/null'
61 );
62 `$cmd`;
63 }
64 )
65);
66
67# Run benchmarks
68$bench->run;
69
70# Output in a single row
71if ($columns) {
72 unless ($no_header) {
73 print join("\t", map { $_->name } $bench->instances), "\n";
74 };
75 print join("\t", map { $_->single_run } $bench->instances), "\n";
76 exit(0);
77};
78
79# Output simple timings for comparation
80foreach my $inst ($bench->instances) {
81 unless ($no_header) {
82 print $inst->name, ': ';
83 };
84 print $inst->single_run, "\n";
85};
86
87exit(0);