3
# Licensed to the Apache Software Foundation (ASF) under one or more
4
# contributor license agreements. See the NOTICE file distributed with
5
# this work for additional information regarding copyright ownership.
6
# The ASF licenses this file to You under the Apache License, Version 2.0
7
# (the "License"); you may not use this file except in compliance with
8
# the License. You may obtain a copy of the License at
10
# http://www.apache.org/licenses/LICENSE-2.0
12
# Unless required by applicable law or agreed to in writing, software
13
# distributed under the License is distributed on an "AS IS" BASIS,
14
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
# See the License for the specific language governing permissions and
16
# limitations under the License.
18
# ------------------------------------------
19
# compare.collation.benchmark.jira.tables.pl
21
# Takes as cmdline parameters two JIRA-formatted benchmark results, as produced
22
# by bm2jira.pl (located in the same directory as this script), and outputs a
23
# third JIRA-formatted comparison table, showing the differences between two
24
# benchmarking runs' java.text and ICU4J columns, after accounting for the
25
# KeywordAnalyzer column; the "ICU4J Improvement" column is ignored.
27
# The difference is calculated as a percentage:
29
# 100 * (patched-rate - unpatched-rate / unpatched-rate)
31
# where the (un)patched-rate is:
33
# 1 / ( elapsed-(un)patched-time - elapsed-KeywordAnalyzer-time)
39
my $usage = "Usage: $0 <unpatched-file> <patched-file>\n";
41
die $usage unless ($#ARGV == 1 && -f $ARGV[0] && -f $ARGV[1]);
45
open UNPATCHED, "<$ARGV[0]" || die "ERROR opening '$ARGV[0]': $!";
47
# ||Language||java.text||ICU4J||KeywordAnalyzer||ICU4J Improvement||
48
# |English|4.51s|2.47s|1.47s|204%|
49
next unless (/^\|([^|]+)\|([^|s]+)s\|([^|s]+)s\|([^|s]+)s/);
50
my ($lang, $jdk_elapsed, $icu_elapsed, $keyword_analyzer_elapsed)
52
$stats{unpatched}{$lang}{jdk} = $jdk_elapsed;
53
$stats{unpatched}{$lang}{icu} = $icu_elapsed;
54
$stats{unpatched}{$lang}{keyword_analyzer} = $keyword_analyzer_elapsed;
58
open PATCHED, "<$ARGV[1]" || die "ERROR opening '$ARGV[1]': $!";
60
# ||Language||java.text||ICU4J||KeywordAnalyzer||ICU4J Improvement||
61
# |English|4.51s|2.47s|1.47s|204%|
62
next unless (/^\|([^|]+)\|([^|s]+)s\|([^|s]+)s\|([^|s]+)s/);
63
my ($lang, $jdk_elapsed, $icu_elapsed, $keyword_analyzer_elapsed)
65
$stats{patched}{$lang}{jdk} = $jdk_elapsed;
66
$stats{patched}{$lang}{icu} = $icu_elapsed;
67
$stats{patched}{$lang}{keyword_analyzer} = $keyword_analyzer_elapsed;
71
print "||Language||java.text improvement||ICU4J improvement||\n";
72
for my $lang (sort keys %{$stats{unpatched}}) {
73
my $keyword_analyzer1 = $stats{unpatched}{$lang}{keyword_analyzer};
74
my $jdk1 = $stats{unpatched}{$lang}{jdk};
75
my $jdk_diff1 = $jdk1 - $keyword_analyzer1;
76
my $icu1 = $stats{unpatched}{$lang}{icu};
77
my $icu_diff1 = $icu1 - $keyword_analyzer1;
79
my $keyword_analyzer2 = $stats{patched}{$lang}{keyword_analyzer};
80
my $jdk2 = $stats{patched}{$lang}{jdk};
81
my $jdk_diff2 = $jdk2 - $keyword_analyzer2;
82
my $icu2 = $stats{patched}{$lang}{icu};
83
my $icu_diff2 = $icu2 - $keyword_analyzer2;
86
= int((1./$jdk_diff2 - 1./$jdk_diff1) / (1./$jdk_diff1) * 1000 + 5) / 10;
88
= int((1./$icu_diff2 - 1./$icu_diff1) / (1./$icu_diff1) * 1000 + 5) / 10;
90
printf "|$lang|%2.1f%%|%2.1f%%|\n", $jdk_impr, $icu_impr;