76 lines
2.3 KiB
PHP
76 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace App\Support;
|
|
|
|
use App\Models\InfrabenchResult;
|
|
use App\Models\ProsebenchResult;
|
|
use App\Models\PsychbenchResult;
|
|
use App\Models\ScenarioRun;
|
|
use App\Models\SoftbenchResult;
|
|
use Illuminate\Support\Collection;
|
|
|
|
/**
|
|
* Typed accessor over the suite registry in config/festbench.php.
|
|
* Single source of truth for import routing, view generation, UI rendering
|
|
* and the suite filter.
|
|
*/
|
|
class Suites
|
|
{
|
|
/** @var array<string, class-string> */
|
|
private const MODELS = [
|
|
'softbench' => SoftbenchResult::class,
|
|
'infrabench' => InfrabenchResult::class,
|
|
'prosebench' => ProsebenchResult::class,
|
|
'psychbench' => PsychbenchResult::class,
|
|
'scenariobench' => ScenarioRun::class,
|
|
];
|
|
|
|
/** Model class handling results for $suite, or null if unregistered. */
|
|
public static function modelFor(?string $suite): ?string
|
|
{
|
|
return self::MODELS[$suite] ?? null;
|
|
}
|
|
|
|
/** Name of the HasMany relation on BenchmarkRun for $suite. */
|
|
public static function runRelation(string $suite): string
|
|
{
|
|
return $suite === 'scenariobench' ? 'scenarioRuns' : $suite.'Results';
|
|
}
|
|
|
|
/** Source table in the festbench SQLite db for $suite. */
|
|
public static function sourceTable(string $suite): string
|
|
{
|
|
return config("festbench.source_tables.{$suite}", 'results');
|
|
}
|
|
|
|
/** All registered suites, active and inactive. */
|
|
public static function all(): array
|
|
{
|
|
return array_keys(self::MODELS);
|
|
}
|
|
|
|
/**
|
|
* Active suites (appear in the suite filter and run-detail rendering).
|
|
*
|
|
* @return Collection<int, string>
|
|
*/
|
|
public static function active(): Collection
|
|
{
|
|
return collect(self::MODELS)
|
|
->filter(fn (string $m, string $suite) => config("festbench.suites.{$suite}.active", false))
|
|
->keys();
|
|
}
|
|
|
|
/**
|
|
* Active suites that participate in the combined all_results view.
|
|
*
|
|
* @return Collection<int, string>
|
|
*/
|
|
public static function inAllResults(): Collection
|
|
{
|
|
return collect(self::MODELS)
|
|
->filter(fn (string $m, string $suite) => config("festbench.suites.{$suite}.active", false)
|
|
&& config("festbench.suites.{$suite}.in_all_results", false))
|
|
->keys();
|
|
}
|
|
}
|