mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 00:39:49 +00:00
69d5249e7f
Publish some TypedData and ForLoop benchmarks to the Dart sdk repo. The benchmarks, authored by the Dart project, were previously in the benchmark-internal repository. Bug: b/298617448 Change-Id: I3327553ac5feca51a2f978e7d9b9c96fac2af121 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/323840 Commit-Queue: William Hesse <whesse@google.com> Reviewed-by: Jonas Termansen <sortie@google.com>
28 lines
684 B
Dart
28 lines
684 B
Dart
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
|
|
// for details. 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:benchmark_harness/benchmark_harness.dart';
|
|
|
|
class IterationBenchmark extends BenchmarkBase {
|
|
List<int> list = List.generate(1000, (i) => i);
|
|
var r = 0;
|
|
void fn(int i) => r = 123 * i;
|
|
IterationBenchmark(name) : super(name);
|
|
}
|
|
|
|
class ForLoop extends IterationBenchmark {
|
|
ForLoop() : super('ForLoop');
|
|
|
|
@override
|
|
void run() {
|
|
for (var i = 0; i < list.length; i++) {
|
|
fn(list[i]);
|
|
}
|
|
}
|
|
}
|
|
|
|
void main() {
|
|
ForLoop().report();
|
|
}
|