Skip to content

Commit

Permalink
completion_metrics.dart change- add an additional group, local refere…
Browse files Browse the repository at this point in the history
…nces, when printing out the output

Change-Id: I38601eb748d0247413725b62718bcabdb1e3e6fa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153020
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jaime Wren <jwren@google.com>
  • Loading branch information
jwren authored and commit-bot@chromium.org committed Jul 1, 2020
1 parent 5d064d2 commit b08ade3
Showing 1 changed file with 38 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,13 @@ bool validArguments(ArgParser parser, ArgResults result) {

/// An indication of the group in which the completion falls for the purposes of
/// subdividing the results.
enum CompletionGroup { instanceMember, staticMember, typeReference, topLevel }
enum CompletionGroup {
instanceMember,
staticMember,
typeReference,
localReference,
topLevel
}

/// A wrapper for the collection of [Counter] and [MeanReciprocalRankComputer]
/// objects for a run of [CompletionMetricsComputer].
Expand Down Expand Up @@ -213,6 +219,9 @@ class CompletionMetrics {
MeanReciprocalRankComputer typeRefMrrComputer =
MeanReciprocalRankComputer('type reference completions');

MeanReciprocalRankComputer localRefMrrComputer =
MeanReciprocalRankComputer('local reference completions');

MeanReciprocalRankComputer topLevelMrrComputer =
MeanReciprocalRankComputer('non-type member completions');

Expand Down Expand Up @@ -246,6 +255,10 @@ class CompletionMetrics {
/// (worst) ranks for completing to type references.
List<CompletionResult> typeRefWorstResults = [];

/// A list of the top [maxWorstResults] completion results with the highest
/// (worst) ranks for completing to local references.
List<CompletionResult> localRefWorstResults = [];

/// A list of the top [maxWorstResults] completion results with the highest
/// (worst) ranks for completing to top-level declarations.
List<CompletionResult> topLevelWorstResults = [];
Expand All @@ -262,6 +275,10 @@ class CompletionMetrics {
/// longest top compute for type references.
List<CompletionResult> typeRefSlowestResults = [];

/// A list of the top [maxSlowestResults] completion results that took the
/// longest top compute for local references.
List<CompletionResult> localRefSlowestResults = [];

/// A list of the top [maxSlowestResults] completion results that took the
/// longest top compute for top-level declarations.
List<CompletionResult> topLevelSlowestResults = [];
Expand Down Expand Up @@ -308,6 +325,10 @@ class CompletionMetrics {
case CompletionGroup.typeReference:
typeRefMrrComputer.addRank(rank);
break;
case CompletionGroup.localReference:
localRefMrrComputer.addRank(rank);
break;

case CompletionGroup.topLevel:
topLevelMrrComputer.addRank(rank);
break;
Expand All @@ -332,6 +353,8 @@ class CompletionMetrics {
return staticMemberSlowestResults;
case CompletionGroup.typeReference:
return typeRefSlowestResults;
case CompletionGroup.localReference:
return localRefSlowestResults;
case CompletionGroup.topLevel:
return topLevelSlowestResults;
}
Expand Down Expand Up @@ -364,6 +387,8 @@ class CompletionMetrics {
return staticMemberWorstResults;
case CompletionGroup.typeReference:
return typeRefWorstResults;
case CompletionGroup.localReference:
return localRefWorstResults;
case CompletionGroup.topLevel:
return topLevelWorstResults;
}
Expand Down Expand Up @@ -535,6 +560,9 @@ class CompletionMetricsComputer {
metrics.typeRefMrrComputer.printMean();
print('');

metrics.localRefMrrComputer.printMean();
print('');

metrics.topLevelMrrComputer.printMean();
print('');

Expand Down Expand Up @@ -610,6 +638,7 @@ class CompletionMetricsComputer {
'Instance members', metrics.instanceMemberSlowestResults);
_printSlowestResults('Static members', metrics.staticMemberSlowestResults);
_printSlowestResults('Type references', metrics.typeRefSlowestResults);
_printSlowestResults('Local references', metrics.localRefSlowestResults);
_printSlowestResults('Top level', metrics.topLevelSlowestResults);
}

Expand All @@ -620,6 +649,7 @@ class CompletionMetricsComputer {
_printWorstResults('Instance members', metrics.instanceMemberWorstResults);
_printWorstResults('Static members', metrics.staticMemberWorstResults);
_printWorstResults('Type references', metrics.topLevelWorstResults);
_printWorstResults('Local references', metrics.localRefWorstResults);
_printWorstResults('Top level', metrics.topLevelWorstResults);
}

Expand Down Expand Up @@ -1053,8 +1083,14 @@ class CompletionResult {
} else {
return CompletionGroup.instanceMember;
}
} else if (expectedCompletion.elementKind == ElementKind.CLASS) {
} else if (expectedCompletion.elementKind == ElementKind.CLASS ||
expectedCompletion.elementKind == ElementKind.MIXIN ||
expectedCompletion.elementKind == ElementKind.ENUM ||
expectedCompletion.elementKind == ElementKind.TYPE_PARAMETER) {
return CompletionGroup.typeReference;
} else if (expectedCompletion.elementKind == ElementKind.LOCAL_VARIABLE ||
expectedCompletion.elementKind == ElementKind.PARAMETER) {
return CompletionGroup.localReference;
}
}
return CompletionGroup.topLevel;
Expand Down

0 comments on commit b08ade3

Please sign in to comment.