674af7e93f
Benchmarks (AOT): - RunTime as Score (bigger is better): - Iteration.deeptree.syncstar(x64): +3450% - Iteration.concat.syncstar(x64): +28% Note: Some other benchmarks (notably ForInGeneratedLoop) are to a lesser degree negatively impacted since they use sync* in a way that incurs the overhead without being able to see any of the benefit. Bug: https://github.com/dart-lang/sdk/issues/37753 Change-Id: I003375ed5104623884bc1cf9c745ba992d0879c1 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/144943 Commit-Queue: Clement Skau <cskau@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com>
35 lines
814 B
Dart
35 lines
814 B
Dart
// Copyright (c) 2020, 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.
|
|
//
|
|
// Test that sync* correctly iterates through nested iterators of both
|
|
// the internal sync* transform _SyncIterable and generic Iterable types.
|
|
|
|
import "package:expect/expect.dart";
|
|
|
|
Iterable<int> outerSyncStar() sync* {
|
|
yield 1;
|
|
// _SyncIterable<int>:
|
|
yield* innerSyncStar();
|
|
yield 4;
|
|
// Generic Iterable<int>:
|
|
yield* [5, 6];
|
|
//
|
|
yield* emptySyncStar();
|
|
yield 7;
|
|
}
|
|
|
|
Iterable<int> innerSyncStar() sync* {
|
|
yield 2;
|
|
yield* [];
|
|
yield* [3];
|
|
}
|
|
|
|
Iterable<int> emptySyncStar() sync* {
|
|
yield* [];
|
|
}
|
|
|
|
main() {
|
|
Expect.listEquals([1, 2, 3, 4, 5, 6, 7], [...outerSyncStar()]);
|
|
}
|