Skip to content

Commit 7abfe99

Browse files
committed
Expose memory allocations in search benchmarks.
1 parent acc82e6 commit 7abfe99

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

app/bin/tools/isolate_search_benchmark.dart

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5+
import 'dart:io';
56
import 'dart:math';
67

78
import 'package:_pub_shared/search/search_form.dart';
@@ -23,13 +24,15 @@ final queries = [
2324
];
2425

2526
Future<void> main(List<String> args) async {
26-
print('Loading...');
27+
print('Started. Current memory: ${ProcessInfo.currentRss ~/ 1024} KiB, '
28+
'max memory: ${ProcessInfo.maxRss ~/ 1024} KiB');
2729
final primaryRunner = await startSearchIsolate(snapshot: args.first);
2830
final reducedRunner = await startSearchIsolate(
2931
snapshot: args.first,
3032
removeTextContent: true,
3133
);
32-
print('Loaded.');
34+
print('Loaded. Current memory: ${ProcessInfo.currentRss ~/ 1024} KiB, '
35+
'max memory: ${ProcessInfo.maxRss ~/ 1024} KiB');
3336

3437
for (var i = 0; i < 5; i++) {
3538
await _benchmark(primaryRunner, primaryRunner);
@@ -39,6 +42,8 @@ Future<void> main(List<String> args) async {
3942

4043
await primaryRunner.close();
4144
await reducedRunner.close();
45+
print('Done. Current memory: ${ProcessInfo.currentRss ~/ 1024} KiB, '
46+
'max memory: ${ProcessInfo.maxRss ~/ 1024} KiB');
4247
}
4348

4449
Future<void> _benchmark(IsolateRunner primary, IsolateRunner reduced) async {

app/bin/tools/sdk_search_benchmark.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,17 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5+
import 'dart:io';
6+
57
import 'package:pub_dev/search/sdk_mem_index.dart';
68

79
/// Loads a Dart SDK search snapshot and executes queries on it, benchmarking their total time to complete.
810
Future<void> main() async {
11+
print('Started. Current memory: ${ProcessInfo.currentRss ~/ 1024} KiB, '
12+
'max memory: ${ProcessInfo.maxRss ~/ 1024} KiB');
913
final index = await createSdkMemIndex();
14+
print('Loaded. Current memory: ${ProcessInfo.currentRss ~/ 1024} KiB, '
15+
'max memory: ${ProcessInfo.maxRss ~/ 1024} KiB');
1016

1117
// NOTE: please add more queries to this list, especially if there is a performance bottleneck.
1218
final queries = [
@@ -25,4 +31,6 @@ Future<void> main() async {
2531
}
2632
sw.stop();
2733
print('${(sw.elapsedMilliseconds / count).toStringAsFixed(2)} ms/request');
34+
print('Done. Current memory: ${ProcessInfo.currentRss ~/ 1024} KiB, '
35+
'max memory: ${ProcessInfo.maxRss ~/ 1024} KiB');
2836
}

app/bin/tools/search_benchmark.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,21 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5+
import 'dart:async';
6+
import 'dart:io';
7+
58
import 'package:_pub_shared/search/search_form.dart';
69
import 'package:pub_dev/search/search_service.dart';
710
import 'package:pub_dev/search/updater.dart';
811

912
/// Loads a search snapshot and executes queries on it, benchmarking their total time to complete.
1013
Future<void> main(List<String> args) async {
14+
print('Started. Current memory: ${ProcessInfo.currentRss ~/ 1024} KiB, '
15+
'max memory: ${ProcessInfo.maxRss ~/ 1024} KiB');
1116
// Assumes that the first argument is a search snapshot file.
1217
final index = await loadInMemoryPackageIndexFromFile(args.first);
18+
print('Loaded. Current memory: ${ProcessInfo.currentRss ~/ 1024} KiB, '
19+
'max memory: ${ProcessInfo.maxRss ~/ 1024} KiB');
1320

1421
// NOTE: please add more queries to this list, especially if there is a performance bottleneck.
1522
final queries = [
@@ -34,4 +41,6 @@ Future<void> main(List<String> args) async {
3441
}
3542
sw.stop();
3643
print('${(sw.elapsedMilliseconds / count).toStringAsFixed(2)} ms/request');
44+
print('Done. Current memory: ${ProcessInfo.currentRss ~/ 1024} KiB, '
45+
'max memory: ${ProcessInfo.maxRss ~/ 1024} KiB');
3746
}

0 commit comments

Comments
 (0)