dart-sdk/benchmarks/SoundSplayTreeSieve/dart/iterable.dart
Kallen Tu 1db1a837f8 Added SoundSplayTreeSieve benchmark for variantly sound interfaces.
Dart2JS
sdk/bin/dart2js_developer sieve.dart --enable-experiment=variance --experiment-new-rti --omit-implicit-checks --out=soundsplay.js --lax-runtime-type-to-string
CollectionSieves-SplayTreeSet-removeLoop(RunTime): 4307.52688172043 us.
CollectionSieves-SoundSplayTreeSet-removeLoop(RunTime): 4344.902386117137 us.

sdk/bin/dart2js_developer sieve.dart --enable-experiment=variance --experiment-new-rti --out=soundsplay.js
CollectionSieves-SplayTreeSet-removeLoop(RunTime): 73714.28571428572 us.
CollectionSieves-SoundSplayTreeSet-removeLoop(RunTime): 73714.28571428572 us.

DDK
pkg/dev_compiler/tool/ddb -d -r chrome --enable-experiment=variance -k sieve.dart
CollectionSieves-SplayTreeSet-removeLoop(RunTime): 29097.17391304348
CollectionSieves-SoundSplayTreeSet-removeLoop(RunTime): 22948.409090909092 us.

Change-Id: Ie78febebe57295d7d5fd10e07d95da118f285cce
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/129303
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
2019-12-20 23:54:15 +00:00

24 lines
913 B
Dart

/// Marker interface for [Iterable] subclasses that have an efficient
/// [length] implementation.
abstract class EfficientLengthIterable<T> extends Iterable<T> {
const EfficientLengthIterable();
/// Returns the number of elements in the iterable.
///
/// This is an efficient operation that doesn't require iterating through
/// the elements.
int get length;
}
/// Creates errors throw by [Iterable] when the element count is wrong.
abstract class IterableElementError {
/// Error thrown thrown by, e.g., [Iterable.first] when there is no result.
static StateError noElement() => StateError("No element");
/// Error thrown by, e.g., [Iterable.single] if there are too many results.
static StateError tooMany() => StateError("Too many elements");
/// Error thrown by, e.g., [List.setRange] if there are too few elements.
static StateError tooFew() => StateError("Too few elements");
}