File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 1+ // Copyright (c) 2024, 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 'package:pub_dev/search/flutter_sdk_mem_index.dart' ;
6+
7+ /// Loads a Dart SDK search snapshot and executes queries on it, benchmarking their total time to complete.
8+ Future <void > main () async {
9+ final index = await createFlutterSdkMemIndex ();
10+
11+ // NOTE: please add more queries to this list, especially if there is a performance bottleneck.
12+ final queries = [
13+ 'chart' ,
14+ 'json' ,
15+ 'camera' ,
16+ 'android camera' ,
17+ 'sql database' ,
18+ ];
19+
20+ final sw = Stopwatch ()..start ();
21+ var count = 0 ;
22+ for (var i = 0 ; i < 100 ; i++ ) {
23+ index! .search (queries[i % queries.length]);
24+ count++ ;
25+ }
26+ sw.stop ();
27+ print ('${(sw .elapsedMilliseconds / count ).toStringAsFixed (2 )} ms/request' );
28+ }
You can’t perform that action at this time.
0 commit comments