"Fossies" - the Fresh Open Source Software Archive 
Member "flutter-3.7.1/dev/devicelab/test/ab_test.dart" (1 Feb 2023, 1600 Bytes) of package /linux/misc/flutter-3.7.1.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.
4
5 import 'package:flutter_devicelab/framework/ab.dart';
6 import 'package:flutter_devicelab/framework/task_result.dart';
7
8 import 'common.dart';
9
10 void main() {
11 test('ABTest', () {
12 final ABTest ab = ABTest('engine', 'test');
13
14 for (int i = 0; i < 5; i++) {
15 final TaskResult aResult = TaskResult.fromJson(<String, dynamic>{
16 'success': true,
17 'data': <String, dynamic>{
18 'i': i,
19 'j': 10 * i,
20 'not_a_metric': 'something',
21 },
22 'benchmarkScoreKeys': <String>['i', 'j'],
23 });
24 ab.addAResult(aResult);
25 final TaskResult bResult = TaskResult.fromJson(<String, dynamic>{
26 'success': true,
27 'data': <String, dynamic>{
28 'i': i + 1,
29 'k': 10 * i + 1,
30 },
31 'benchmarkScoreKeys': <String>['i', 'k'],
32 });
33 ab.addBResult(bResult);
34 }
35 ab.finalize();
36
37 expect(
38 ab.rawResults(),
39 'i:\n'
40 ' A:\t0.00\t1.00\t2.00\t3.00\t4.00\t\n'
41 ' B:\t1.00\t2.00\t3.00\t4.00\t5.00\t\n'
42 'j:\n'
43 ' A:\t0.00\t10.00\t20.00\t30.00\t40.00\t\n'
44 ' B:\tN/A\n'
45 'k:\n'
46 ' A:\tN/A\n'
47 ' B:\t1.00\t11.00\t21.00\t31.00\t41.00\t\n',
48 );
49 expect(
50 ab.printSummary(),
51 'Score\tAverage A (noise)\tAverage B (noise)\tSpeed-up\n'
52 'i\t2.00 (70.71%)\t3.00 (47.14%)\t0.67x\t\n'
53 'j\t20.00 (70.71%)\t\t\n'
54 'k\t\t21.00 (67.34%)\t\n');
55 });
56 }