[benchmarks] Add more test cases to ListCopy benchmarks.

This is the follow-up for the discussion on
https://dart-review.googlesource.com/c/sdk/+/152700

Change-Id: Ifeeafcdc312c4f7df7e0be1cc806b972b8c18078
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152709
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Jonas Termansen <sortie@google.com>
Auto-Submit: Alexander Markov <alexmarkov@google.com>
This commit is contained in:
Alexander Markov 2020-07-01 16:01:40 +00:00 committed by Jonas Termansen
parent 8cc3d415e7
commit 9ae1448ef0
2 changed files with 18 additions and 0 deletions

View file

@ -133,6 +133,15 @@ List<Benchmark> makeBenchmarks(int length) => [
Benchmark('spread.int', length, () {
output = <int>[...input as dynamic];
}),
Benchmark('spread.int.cast', length, () {
output = <int>[...input.cast<int>()];
}),
Benchmark('spread.int.map', length, () {
output = <int>[...input.map((x) => x as int)];
}),
Benchmark('for.int', length, () {
output = <int>[for (var n in input) n as int];
}),
];
void main() {

View file

@ -133,6 +133,15 @@ List<Benchmark> makeBenchmarks(int length) => [
Benchmark('spread.int', length, () {
output = <int>[...input];
}),
Benchmark('spread.int.cast', length, () {
output = <int>[...input.cast<int>()];
}),
Benchmark('spread.int.map', length, () {
output = <int>[...input.map((x) => x as int)];
}),
Benchmark('for.int', length, () {
output = <int>[for (var n in input) n as int];
}),
];
void main() {