flutter/packages/flutter_driver/lib/src/driver/percentile_utils.dart
Dan Field ad49e25a6b
Revert "[null-safety] reland: migrate app side flutter driver to null-safety (#67441)" (#67561)
This reverts commit d411242468773a800945f0d8c6cfcf40c7ea8e44.
2020-10-07 13:57:49 -07:00

12 lines
431 B
Dart

// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/// Returns the [p]-th percentile element from the [doubles].
/// `List<doubles>` will be sorted.
double findPercentile(List<double> doubles, double p) {
assert(doubles.isNotEmpty);
doubles.sort();
return doubles[((doubles.length - 1) * (p / 100)).round()];
}