"Fossies" - the Fresh Open Source Software Archive

Member "flutter-1.22.4/packages/flutter_driver/lib/src/driver/percentile_utils.dart" (13 Nov 2020, 431 Bytes) of package /linux/misc/flutter-1.22.4.tar.gz:

As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Dart source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

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