mirror of
https://github.com/pese-git/cherrypick.git
synced 2026-01-24 05:25:19 +00:00
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.
This commit is contained in:
29
benchmark_cherrypick/lib/benchmark_utils.dart
Normal file
29
benchmark_cherrypick/lib/benchmark_utils.dart
Normal file
@@ -0,0 +1,29 @@
|
||||
import 'package:cherrypick/cherrypick.dart';
|
||||
|
||||
/// Миксин для упрощения работы с CherryPick Scope в бенчмарках.
|
||||
mixin BenchmarkWithScope {
|
||||
Scope? _scope;
|
||||
|
||||
/// Отключить глобальные проверки циклов и создать корневой scope с модулями.
|
||||
void setupScope(List<Module> modules,
|
||||
{bool disableCycleDetection = true,
|
||||
bool disableCrossScopeCycleDetection = true}) {
|
||||
if (disableCycleDetection) {
|
||||
CherryPick.disableGlobalCycleDetection();
|
||||
}
|
||||
if (disableCrossScopeCycleDetection) {
|
||||
CherryPick.disableGlobalCrossScopeCycleDetection();
|
||||
}
|
||||
_scope = CherryPick.openRootScope();
|
||||
_scope!.installModules(modules);
|
||||
}
|
||||
|
||||
/// Закрывает текущий scope.
|
||||
void teardownScope() {
|
||||
CherryPick.closeRootScope();
|
||||
_scope = null;
|
||||
}
|
||||
|
||||
/// Получить текущий scope. Не null после setupScope.
|
||||
Scope get scope => _scope!;
|
||||
}
|
||||
Reference in New Issue
Block a user