Skip to content
This repository was archived by the owner on Sep 26, 2023. It is now read-only.

Commit eeafde7

Browse files
authored
Revert "Minor performance improvement to Distribution (#733)" (#739)
This reverts commit a9731e7.
1 parent dac077d commit eeafde7

File tree

1 file changed

+5
-16
lines changed

1 file changed

+5
-16
lines changed

gax/src/main/java/com/google/api/gax/core/Distribution.java

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -75,22 +75,11 @@ public int getPercentile(double percentile) {
7575
Preconditions.checkArgument(percentile <= 100.0);
7676

7777
long targetRank = (long) Math.ceil(percentile * count.get() / 100);
78-
if (percentile < 50.0) {
79-
long rank = 0;
80-
for (int i = 0; i < buckets.length(); i++) {
81-
rank += buckets.get(i);
82-
if (rank >= targetRank) {
83-
return i;
84-
}
85-
}
86-
} else {
87-
long rank = count.get();
88-
for (int i = buckets.length() - 1; i >= 0; i--) {
89-
long current = buckets.get(i);
90-
if (rank - current < targetRank) {
91-
return i;
92-
}
93-
rank -= current;
78+
long rank = 0;
79+
for (int i = 0; i < buckets.length(); i++) {
80+
rank += buckets.get(i);
81+
if (rank >= targetRank) {
82+
return i;
9483
}
9584
}
9685
return buckets.length();

0 commit comments

Comments
 (0)