Skip to content

Commit

Permalink
WIP, not for submit: benchmark analyzer-based generation / incrementa…
Browse files Browse the repository at this point in the history
…l generation by number of files.
  • Loading branch information
davidmorgan committed Dec 20, 2024
1 parent 998d544 commit d8e42bf
Show file tree
Hide file tree
Showing 5 changed files with 251 additions and 71 deletions.
71 changes: 71 additions & 0 deletions _test/bin/benchmark.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import 'dart:io';

import '../test/common/utils.dart';

Future<void> main() async {
// only works in test
inTest = false;
ensureCleanGitClient();
print('Initial build.');
await runBuild();
print('Done.');

print('Files,Build time/ms,Incremental time/ms');
for (final size in [
100,
500,
1000,
1500,
2000,
2500,
3000,
3500,
4000,
4500,
5000,
]) {
stdout.write('$size,');

await createFile(
'lib/bv_app.dart',
[
for (var i = 0; i != size; ++i) "import 'built_value${i + 1}.dart';",
].join('\n'),
);

for (var i = 0; i != size; ++i) {
await createFile('lib/built_value${i + 1}.dart', '''
import 'package:built_value/built_value.dart';
import 'bv_app.dart';
part 'built_value${i + 1}.g.dart';
abstract class Value implements Built<Value, ValueBuilder> {
Value._();
factory Value([void Function(ValueBuilder)? updates]) = _\$Value;
}
''');
}
final stopwatch = Stopwatch()..start();
await runBuild();
stdout.write('${stopwatch.elapsedMilliseconds},');

await createFile('lib/built_value1.dart', '''
import 'package:built_value/built_value.dart';
import 'bv_app.dart';
part 'built_value1.g.dart';
abstract class Value implements Built<Value, ValueBuilder> {
int get x;
Value._();
factory Value([void Function(ValueBuilder)? updates]) = _\$Value;
}
''');
stopwatch.reset();
await runBuild();
print(stopwatch.elapsedMilliseconds);
}
}
10 changes: 10 additions & 0 deletions _test/lib/built_value1.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import 'package:built_value/built_value.dart';



part 'built_value1.g.dart';

abstract class Value implements Built<Value, ValueBuilder> {
Value._();
factory Value([void Function(ValueBuilder)? updates]) = _$Value;
}
65 changes: 65 additions & 0 deletions _test/lib/built_value1.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions _test/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ environment:
sdk: ^3.6.0

dependencies:
built_value: ^8.9.0
web: ^1.0.0

dev_dependencies:
Expand All @@ -18,6 +19,7 @@ dev_dependencies:
build_runner_core: any
build_test: any
build_web_compilers: any
built_value_generator: ^8.9.0
dart_flutter_team_lints: ^3.1.0
io: ^1.0.0
path: ^1.8.0
Expand Down
Loading

0 comments on commit d8e42bf

Please sign in to comment.