blob: d8e3b2ae837fe0ef692f33afe316322ee9a5f4b0 [file] [log] [blame]
Akronaa229a22020-02-18 13:44:25 +01001#!/usr/bin/env perl
2use strict;
3use warnings;
4use Dumbbench;
5use File::Basename 'dirname';
6use File::Spec::Functions qw/catfile 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 = 'tei2korapxml';
29
30my $f = dirname(__FILE__);
31my $script = rel2abs(catfile($f, '..', 'script', $SCRIPT_NAME));
32
33# Load example file
34my $file = rel2abs(catfile($f, '..', 't', 'data', 'goe_sample.i5.xml'));
35
36# Create a new benchmark object
37my $bench = Dumbbench->new(
38 verbosity => 0
39);
40
41# Add benchmark instances
42$bench->add_instances(
43 Dumbbench::Instance::PerlSub->new(
44 name => 'SimpleConversion',
45 code => sub {
46 `cat '$file' | perl '$script' > /dev/null 2>&1`
47 }
48 )
49);
50
51# Run benchmarks
52$bench->run;
53
54# Output in a single row
55if ($columns) {
56 unless ($no_header) {
57 print join("\t", map { $_->name } $bench->instances), "\n";
58 };
59 print join("\t", map { $_->result->raw_number } $bench->instances), "\n";
60 exit(0);
61};
62
63# Output simple timings for comparation
64foreach my $inst ($bench->instances) {
65 unless ($no_header) {
66 print $inst->name, ': ';
67 };
68 print $inst->result->raw_number, "\n";
69};
70
71exit(0);
72
73__END__