Files
cherrypick/benchmark_cherrypick/lib/scope_override_benchmark.dart
Sergey Penkovsky 926bbf15f4 refactor(benchmarks): unify benchmark structure, enable CLI parameterization, run matrix, add CSV/JSON/pretty output
- All benchmarks now use a unified base mixin for setup/teardown (BenchmarkWithScope).
- Added args package support: CLI flags for choosing benchmarks, chain counts, nesting depths, output format.
- Support for running benchmarks in matrix mode (multiple parameter sets).
- Machine-readable output: csv, json, pretty-table.
- Loop and naming lint fixes, unused imports removed.
2025-08-06 13:30:30 +03:00

49 lines
1.1 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// ignore: depend_on_referenced_packages
import 'package:benchmark_harness/benchmark_harness.dart';
import 'package:cherrypick/cherrypick.dart';
import 'benchmark_utils.dart';
class Shared {}
class ParentImpl extends Shared {}
class ChildImpl extends Shared {}
class ParentModule extends Module {
@override
void builder(Scope currentScope) {
bind<Shared>().toProvide(() => ParentImpl()).singleton();
}
}
class ChildOverrideModule extends Module {
@override
void builder(Scope currentScope) {
bind<Shared>().toProvide(() => ChildImpl()).singleton();
}
}
class ScopeOverrideBenchmark extends BenchmarkBase with BenchmarkWithScope {
ScopeOverrideBenchmark() : super('ScopeOverride (child overrides parent)');
late Scope child;
@override
void setup() {
setupScope([ParentModule()]);
child = scope.openSubScope('child');
child.installModules([ChildOverrideModule()]);
}
@override
void teardown() {
teardownScope();
}
@override
void run() {
// Должен возвращать ChildImpl, а не ParentImpl
final resolved = child.resolve<Shared>();
assert(resolved is ChildImpl);
}
}