@@ -95,6 +95,11 @@ const String SKIP_OLD_RELEVANCE = 'skip-old-relevance';
95
95
/// A flag that causes additional output to be produced.
96
96
const String VERBOSE = 'verbose' ;
97
97
98
+ /// A [Counter] to track the performance of the new relevance to the old
99
+ /// relevance.
100
+ Counter oldVsNewComparison =
101
+ Counter ('use old vs new relevance rank comparison' );
102
+
98
103
/// Create a parser that can be used to parse the command-line arguments.
99
104
ArgParser createArgParser () {
100
105
return ArgParser ()
@@ -477,6 +482,12 @@ class CompletionMetricsComputer {
477
482
printMetrics (metricsOldMode);
478
483
}
479
484
printMetrics (metricsNewMode);
485
+
486
+ print ('' );
487
+ print ('====================' );
488
+ oldVsNewComparison.printCounterValues ();
489
+ print ('====================' );
490
+
480
491
if (verbose) {
481
492
printWorstResults (metricsNewMode);
482
493
printSlowestResults (metricsNewMode);
@@ -485,7 +496,7 @@ class CompletionMetricsComputer {
485
496
return resultCode;
486
497
}
487
498
488
- bool forEachExpectedCompletion (
499
+ int forEachExpectedCompletion (
489
500
CompletionRequestImpl request,
490
501
MetricsSuggestionListener listener,
491
502
ExpectedCompletion expectedCompletion,
@@ -496,14 +507,14 @@ class CompletionMetricsComputer {
496
507
bool doPrintMissedCompletions) {
497
508
assert (suggestions != null );
498
509
499
- var successfulCompletion ;
510
+ var rank ;
500
511
501
512
var place = placementInSuggestionList (suggestions, expectedCompletion);
502
513
503
514
metrics.mrrComputer.addRank (place.rank);
504
515
505
516
if (place.denominator != 0 ) {
506
- successfulCompletion = true ;
517
+ rank = place.rank ;
507
518
508
519
metrics.completionCounter.count ('successful' );
509
520
@@ -518,7 +529,7 @@ class CompletionMetricsComputer {
518
529
metrics.insertionLengthTheoretical
519
530
.addValue (expectedCompletion.completion.length - charsBeforeTop);
520
531
} else {
521
- successfulCompletion = false ;
532
+ rank = - 1 ;
522
533
523
534
metrics.completionCounter.count ('unsuccessful' );
524
535
@@ -544,7 +555,7 @@ class CompletionMetricsComputer {
544
555
print ('' );
545
556
}
546
557
}
547
- return successfulCompletion ;
558
+ return rank ;
548
559
}
549
560
550
561
void printMetrics (CompletionMetrics metrics) {
@@ -864,7 +875,7 @@ class CompletionMetricsComputer {
864
875
// and results are collected with varying settings for
865
876
// comparison:
866
877
867
- Future <bool > handleExpectedCompletion (
878
+ Future <int > handleExpectedCompletion (
868
879
{MetricsSuggestionListener listener,
869
880
@required CompletionMetrics metrics,
870
881
@required bool printMissedCompletions,
@@ -910,33 +921,39 @@ class CompletionMetricsComputer {
910
921
911
922
// First we compute the completions useNewRelevance set to
912
923
// false:
913
- var oldRelevanceSucceeded = false ;
924
+ var oldRank ;
914
925
if (! skipOldRelevance) {
915
- oldRelevanceSucceeded = await handleExpectedCompletion (
926
+ oldRank = await handleExpectedCompletion (
916
927
metrics: metricsOldMode,
917
928
printMissedCompletions: false ,
918
929
useNewRelevance: false );
919
930
}
920
931
921
932
// And again here with useNewRelevance set to true:
922
933
var listener = MetricsSuggestionListener ();
923
- var newRelevanceSucceeded = await handleExpectedCompletion (
934
+ var newRank = await handleExpectedCompletion (
924
935
listener: listener,
925
936
metrics: metricsNewMode,
926
937
printMissedCompletions: verbose,
927
938
useNewRelevance: true );
928
939
929
- if (! skipOldRelevance &&
930
- verbose &&
931
- oldRelevanceSucceeded != newRelevanceSucceeded) {
932
- if (newRelevanceSucceeded) {
940
+ if (! skipOldRelevance && newRank != - 1 && oldRank != - 1 ) {
941
+ if (newRank <= oldRank) {
942
+ oldVsNewComparison.count ('new relevance' );
943
+ } else {
944
+ oldVsNewComparison.count ('old relevance' );
945
+ }
946
+ }
947
+
948
+ if (! skipOldRelevance && verbose) {
949
+ if (newRank > 0 && oldRank < 0 ) {
933
950
print (' ===========' );
934
951
print (
935
952
' The `useNewRelevance = true` generated a completion that `useNewRelevance = false` did not:' );
936
953
print (' $expectedCompletion ' );
937
954
print (' ===========' );
938
955
print ('' );
939
- } else {
956
+ } else if (newRank < 0 && oldRank > 0 ) {
940
957
print (' ===========' );
941
958
print (
942
959
' The `useNewRelevance = false` generated a completion that `useNewRelevance = true` did not:' );
0 commit comments