File tree Expand file tree Collapse file tree 4 files changed +98
-0
lines changed
benchmarks/EventLoopLatencyRegexp Expand file tree Collapse file tree 4 files changed +98
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
2
+ // for details. All rights reserved. Use of this source code is governed by a
3
+ // BSD-style license that can be found in the LICENSE file.
4
+
5
+ import 'dart:isolate' ;
6
+
7
+ import 'regexp_benchmark.dart' ;
8
+ import '../../EventLoopLatencyJson/dart/latency.dart' ;
9
+
10
+ main () async {
11
+ final exitPort = ReceivePort ();
12
+ final exitFuture = exitPort.first;
13
+ final isolate = await Isolate .spawn (run, null , onExit: exitPort.sendPort);
14
+
15
+ // Measure event loop latency.
16
+ const tickDuration = const Duration (milliseconds: 1 );
17
+ const numberOfTicks = 8 * 1000 ; // min 8 seconds.
18
+ final EventLoopLatencyStats stats =
19
+ await measureEventLoopLatency (tickDuration, numberOfTicks);
20
+
21
+ // Kill isolate & wait until it's dead.
22
+ isolate.kill (priority: Isolate .immediate);
23
+ await exitFuture;
24
+
25
+ // Report event loop latency statistics.
26
+ stats.report ('EventLoopLatencyRegexp' );
27
+ }
28
+
29
+ void run (dynamic msg) {
30
+ while (true ) {
31
+ RegexpBenchmark ().run ();
32
+ }
33
+ }
Original file line number Diff line number Diff line change
1
+ // Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
2
+ // for details. All rights reserved. Use of this source code is governed by a
3
+ // BSD-style license that can be found in the LICENSE file.
4
+
5
+ import 'dart:math' ;
6
+ import 'dart:convert' ;
7
+
8
+ class RegexpBenchmark {
9
+ void run () {
10
+ final re = RegExp (r'(x+)*y' );
11
+ final s = 'x' * 26 + '' ;
12
+ re.allMatches (s).iterator.moveNext ();
13
+ }
14
+ }
Original file line number Diff line number Diff line change
1
+ // Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
2
+ // for details. All rights reserved. Use of this source code is governed by a
3
+ // BSD-style license that can be found in the LICENSE file.
4
+
5
+ // @dart=2.9
6
+
7
+ import 'dart:isolate' ;
8
+
9
+ import 'json_benchmark.dart' ;
10
+ import '../../EventLoopLatencyJson/dart2/latency.dart' ;
11
+
12
+ main () async {
13
+ final exitPort = ReceivePort ();
14
+ final exitFuture = exitPort.first;
15
+ final isolate = await Isolate .spawn (run, null , onExit: exitPort.sendPort);
16
+
17
+ // Measure event loop latency.
18
+ const tickDuration = const Duration (milliseconds: 1 );
19
+ const numberOfTicks = 8 * 1000 ; // min 8 seconds.
20
+ final EventLoopLatencyStats stats =
21
+ await measureEventLoopLatency (tickDuration, numberOfTicks);
22
+
23
+ // Kill isolate & wait until it's dead.
24
+ isolate.kill (priority: Isolate .immediate);
25
+ await exitFuture;
26
+
27
+ // Report event loop latency statistics.
28
+ stats.report ('EventLoopLatencyRegexp' );
29
+ }
30
+
31
+ void run (dynamic msg) {
32
+ while (true ) {
33
+ RegexpBenchmark ().run ();
34
+ }
35
+ }
Original file line number Diff line number Diff line change
1
+ // Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
2
+ // for details. All rights reserved. Use of this source code is governed by a
3
+ // BSD-style license that can be found in the LICENSE file.
4
+
5
+ // @dart=2.9
6
+
7
+ import 'dart:math' ;
8
+ import 'dart:convert' ;
9
+
10
+ class RegexpBenchmark {
11
+ void run () {
12
+ final re = RegExp (r'(x+)*y' );
13
+ final s = 'x' * 26 + '' ;
14
+ re.allMatches (s).iterator.moveNext ();
15
+ }
16
+ }
You can’t perform that action at this time.
0 commit comments