File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change 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:math' ;
6+
57import 'benchmark.dart' ;
68
79/// The shape of the dependency graph.
@@ -26,7 +28,10 @@ enum Shape {
2628 ///
2729 /// Considered in alphanumeric order, each one has a dependency on the one
2830 /// before. The first library depends on `app.dart` .
29- backwards;
31+ backwards,
32+
33+ /// Randomly connected libraries.
34+ random;
3035
3136 Iterable <String > importNames (
3237 int libraryNumber, {
@@ -59,6 +64,21 @@ enum Shape {
5964 benchmarkSize: benchmarkSize,
6065 ),
6166 ];
67+ case Shape .random:
68+ // Use random.nextInt(random.nextInt(...)) to get a distribution of
69+ // imports biased towards lower number libraries, which is more
70+ // realistic than flat random imports.
71+ final numberOfImports = _random.nextInt (_random.nextInt (10 ) + 1 );
72+ return [
73+ if (_random.nextInt (libraryNumber + 1 ) == 0 ) 'app.dart' ,
74+ for (var i = 0 ; i != numberOfImports; ++ i)
75+ Benchmarks .libraryName (
76+ _random.nextInt (_random.nextInt (benchmarkSize) + 1 ),
77+ benchmarkSize: benchmarkSize,
78+ ),
79+ ];
6280 }
6381 }
6482}
83+
84+ final _random = Random (0 );
You can’t perform that action at this time.
0 commit comments