4c20cedd30
Now that I'm able to open the entire SDK in VSC, I'm fixing some of the analysis issues in various files (carefully) without changing their meaning. In this case, I removed unnecessary imports from benchmarks. In regexp_benchmark I ignored one warning which likely would have changed the behavior of the code. BUG=https://github.com/dart-lang/sdk/issues/52419 Change-Id: I9a195a4e45121313bd9f065f2579a165c3fec05b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/303901 Auto-Submit: Eric Seidel <eric@shorebird.dev> Reviewed-by: William Hesse <whesse@google.com> Commit-Queue: William Hesse <whesse@google.com>
44 lines
1.2 KiB
Dart
44 lines
1.2 KiB
Dart
// Copyright (c) 2022, 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.
|
|
//
|
|
// This test ensures that there are no long pauses when sending large objects
|
|
// via exit/send.
|
|
|
|
import 'dart:async';
|
|
import 'dart:isolate';
|
|
|
|
import 'latency.dart';
|
|
|
|
Future<void> main() async {
|
|
final statsFuture =
|
|
measureEventLoopLatency(const Duration(milliseconds: 1), 4000, work: () {
|
|
// Every 1 ms we allocate some objects which may trigger GC some time.
|
|
for (int i = 0; i < 32; i++) {
|
|
List.filled(32 * 1024 ~/ 8, null);
|
|
}
|
|
});
|
|
|
|
final result = await compute(() {
|
|
final l = <dynamic>[];
|
|
for (int i = 0; i < 10 * 1000 * 1000; ++i) {
|
|
l.add(Object());
|
|
}
|
|
return l;
|
|
});
|
|
if (result.length != 10 * 1000 * 1000) throw 'failed';
|
|
|
|
final stats = await statsFuture;
|
|
stats.report('IsolateSendExitLatency');
|
|
}
|
|
|
|
Future<T> compute<T>(T Function() fun) {
|
|
final rp = ReceivePort();
|
|
final sp = rp.sendPort;
|
|
Isolate.spawn((_) {
|
|
final value = fun();
|
|
Isolate.exit(sp, value);
|
|
}, null);
|
|
return rp.first.then((t) => t as T);
|
|
}
|