blob: bc470d51b4f03c04c1888618eae01d366c11ae83 [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(
Akron414ec952020-08-03 15:48:43 +020049 name => 'Script-ExampleRun-1',
Akron6e886f72020-02-19 07:42:32 +010050 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 };
Akron9711ed32020-02-19 08:10:29 +010075 print join("\t", map { $_->result->raw_number } $bench->instances), "\n";
Akron6e886f72020-02-19 07:42:32 +010076 exit(0);
77};
78
79# Output simple timings for comparation
80foreach my $inst ($bench->instances) {
81 unless ($no_header) {
82 print $inst->name, ': ';
83 };
Akron9711ed32020-02-19 08:10:29 +010084 print $inst->result->raw_number, "\n";
Akron6e886f72020-02-19 07:42:32 +010085};
86
87exit(0);