google_benchmark_test.dart 1.06 KB
Newer Older
Yuqian Li's avatar
Yuqian Li committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
// 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.

import 'package:metrics_center/src/common.dart';
import 'package:metrics_center/google_benchmark.dart';

import 'common.dart';
import 'utility.dart';

void main() {
  test('GoogleBenchmarkParser parses example json.', () async {
    final List<MetricPoint> points =
        await GoogleBenchmarkParser.parse('test/example_google_benchmark.json');
    expect(points.length, 6);
    expectSetMatch(
      points.map((MetricPoint p) => p.value),
      <int>[101, 101, 4460, 4460, 6548, 6548],
    );
    expectSetMatch(
      points.map((MetricPoint p) => p.tags[kSubResultKey]),
      <String>[
        'cpu_time',
        'real_time',
        'cpu_coefficient',
        'real_coefficient',
      ],
    );
    expectSetMatch(
      points.map((MetricPoint p) => p.tags[kNameKey]),
      <String>[
        'BM_PaintRecordInit',
        'BM_ParagraphShortLayout',
        'BM_ParagraphStylesBigO_BigO',
      ],
    );
  });
}