~slub.team/goobi-indexserver/3.x

« back to all changes in this revision

Viewing changes to lucene/contrib/benchmark/scripts/compare.collation.benchmark.tables.pl

  • Committer: Sebastian Meyer
  • Date: 2012-08-03 09:12:40 UTC
  • Revision ID: sebastian.meyer@slub-dresden.de-20120803091240-x6861b0vabq1xror
Remove Lucene and Solr source code and add patches instead
Fix Bug #985487: Auto-suggestion for the search interface

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/perl
2
 
#
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
9
 
10
 
#     http://www.apache.org/licenses/LICENSE-2.0
11
 
#
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.
17
 
#
18
 
# ------------------------------------------
19
 
# compare.collation.benchmark.jira.tables.pl
20
 
#
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.
26
 
#
27
 
# The difference is calculated as a percentage:
28
 
#
29
 
#   100 * (patched-rate - unpatched-rate / unpatched-rate)
30
 
#
31
 
# where the (un)patched-rate is:
32
 
#
33
 
#   1 / ( elapsed-(un)patched-time - elapsed-KeywordAnalyzer-time)
34
 
#
35
 
 
36
 
use strict;
37
 
use warnings;
38
 
 
39
 
my $usage = "Usage: $0 <unpatched-file> <patched-file>\n";
40
 
 
41
 
die $usage unless ($#ARGV == 1 && -f $ARGV[0] && -f $ARGV[1]);
42
 
 
43
 
my %stats = ();
44
 
 
45
 
open UNPATCHED, "<$ARGV[0]" || die "ERROR opening '$ARGV[0]': $!";
46
 
while (<UNPATCHED>) {
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)
51
 
    = ($1, $2, $3, $4);
52
 
  $stats{unpatched}{$lang}{jdk} = $jdk_elapsed;
53
 
  $stats{unpatched}{$lang}{icu} = $icu_elapsed;
54
 
  $stats{unpatched}{$lang}{keyword_analyzer} = $keyword_analyzer_elapsed;
55
 
}
56
 
close UNPATCHED;
57
 
 
58
 
open PATCHED, "<$ARGV[1]" || die "ERROR opening '$ARGV[1]': $!";
59
 
while (<PATCHED>) {
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)
64
 
    = ($1, $2, $3, $4);
65
 
  $stats{patched}{$lang}{jdk} = $jdk_elapsed;
66
 
  $stats{patched}{$lang}{icu} = $icu_elapsed;
67
 
  $stats{patched}{$lang}{keyword_analyzer} = $keyword_analyzer_elapsed;
68
 
}
69
 
close PATCHED;
70
 
 
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;
78
 
 
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;
84
 
 
85
 
  my $jdk_impr 
86
 
    = int((1./$jdk_diff2 - 1./$jdk_diff1) / (1./$jdk_diff1) * 1000 + 5) / 10;
87
 
  my $icu_impr
88
 
    = int((1./$icu_diff2 - 1./$icu_diff1) / (1./$icu_diff1) * 1000 + 5) / 10;
89
 
 
90
 
  printf "|$lang|%2.1f%%|%2.1f%%|\n", $jdk_impr, $icu_impr;
91
 
}