-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge 144ea5b into dev
- Loading branch information
Showing
20 changed files
with
2,528 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// 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 ForEach extends IterationBenchmark { | ||
ForEach() : super('ForEachLoop'); | ||
|
||
@override | ||
void run() { | ||
list.forEach(fn); | ||
} | ||
} | ||
|
||
void main() { | ||
ForEach().report(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// 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. | ||
|
||
// @dart=2.9 | ||
|
||
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 ForEach extends IterationBenchmark { | ||
ForEach() : super('ForEachLoop'); | ||
|
||
@override | ||
void run() { | ||
list.forEach(fn); | ||
} | ||
} | ||
|
||
void main() { | ||
ForEach().report(); | ||
} |
33 changes: 33 additions & 0 deletions
33
benchmarks/ForInGeneratedLoop/dart/ForInGeneratedLoop.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// 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); | ||
} | ||
|
||
Iterable<int> generateElements(List<int> list) sync* { | ||
for (var i = 0; i < list.length; i++) { | ||
yield list[i]; | ||
} | ||
} | ||
|
||
class ForInGenerated extends IterationBenchmark { | ||
ForInGenerated() : super('ForInGeneratedLoop'); | ||
|
||
@override | ||
void run() { | ||
for (var item in generateElements(list)) { | ||
fn(item); | ||
} | ||
} | ||
} | ||
|
||
void main() { | ||
ForInGenerated().report(); | ||
} |
35 changes: 35 additions & 0 deletions
35
benchmarks/ForInGeneratedLoop/dart2/ForInGeneratedLoop.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// 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. | ||
|
||
// @dart=2.9 | ||
|
||
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); | ||
} | ||
|
||
Iterable<int> generateElements(List<int> list) sync* { | ||
for (var i = 0; i < list.length; i++) { | ||
yield list[i]; | ||
} | ||
} | ||
|
||
class ForInGenerated extends IterationBenchmark { | ||
ForInGenerated() : super('ForInGeneratedLoop'); | ||
|
||
@override | ||
void run() { | ||
for (var item in generateElements(list)) { | ||
fn(item); | ||
} | ||
} | ||
} | ||
|
||
void main() { | ||
ForInGenerated().report(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// 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 ForIn extends IterationBenchmark { | ||
ForIn() : super('ForInLoop'); | ||
|
||
@override | ||
void run() { | ||
for (var item in list) { | ||
fn(item); | ||
} | ||
} | ||
} | ||
|
||
void main() { | ||
ForIn().report(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// 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. | ||
|
||
// @dart=2.9 | ||
|
||
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 ForIn extends IterationBenchmark { | ||
ForIn() : super('ForInLoop'); | ||
|
||
@override | ||
void run() { | ||
for (var item in list) { | ||
fn(item); | ||
} | ||
} | ||
} | ||
|
||
void main() { | ||
ForIn().report(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// 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(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// 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. | ||
|
||
// @dart=2.9 | ||
|
||
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(); | ||
} |
Oops, something went wrong.