style: run clang-format and configure pre-commit hooks

This commit is contained in:
AI-anonymous
2026-05-20 00:18:23 +02:00
parent 041eab7155
commit 3b15770437
28 changed files with 2226 additions and 2061 deletions

View File

@@ -1,45 +1,47 @@
#include <benchmark/benchmark.h>
#include "fces/population.hpp"
#include "fces/controller.hpp"
#include "fces/population.hpp"
#include <benchmark/benchmark.h>
using namespace fces;
static void BM_ControllerDecideUpdate(benchmark::State& state) {
FuzzyController ctrl;
std::vector<std::vector<float>> stats(state.range(0), {0.1f, 0.2f, 0.3f, 0.4f, 0.5f});
static void BM_ControllerDecideUpdate(benchmark::State &state) {
FuzzyController ctrl;
std::vector<std::vector<float>> stats(state.range(0),
{0.1f, 0.2f, 0.3f, 0.4f, 0.5f});
for (auto _ : state) {
auto actions = ctrl.decide_update(stats, 0.0f, 0.5f, 0.0f, 0.1f, 0.0f, 0.0f, 1.0f, 0.0f);
benchmark::DoNotOptimize(actions);
}
for (auto _ : state) {
auto actions = ctrl.decide_update(stats, 0.0f, 0.5f, 0.0f, 0.1f, 0.0f, 0.0f,
1.0f, 0.0f);
benchmark::DoNotOptimize(actions);
}
}
BENCHMARK(BM_ControllerDecideUpdate)->Arg(10)->Arg(50)->Arg(200);
static void BM_Evolve(benchmark::State& state) {
Population pop(state.range(0));
static void BM_Evolve(benchmark::State &state) {
Population pop(state.range(0));
for (auto _ : state) {
pop.evolve(2.0f, -0.01f, 0.5f);
}
for (auto _ : state) {
pop.evolve(2.0f, -0.01f, 0.5f);
}
}
BENCHMARK(BM_Evolve)->Arg(50)->Arg(100)->Arg(200);
static void BM_Mutation(benchmark::State& state) {
FuzzyController ctrl;
static void BM_Mutation(benchmark::State &state) {
FuzzyController ctrl;
for (auto _ : state) {
auto child = ctrl.mutate(2.0f, 1.0f);
benchmark::DoNotOptimize(child);
}
for (auto _ : state) {
auto child = ctrl.mutate(2.0f, 1.0f);
benchmark::DoNotOptimize(child);
}
}
BENCHMARK(BM_Mutation);
static void BM_Crossover(benchmark::State& state) {
FuzzyController a, b;
static void BM_Crossover(benchmark::State &state) {
FuzzyController a, b;
for (auto _ : state) {
auto child = a.crossover(b);
benchmark::DoNotOptimize(child);
}
for (auto _ : state) {
auto child = a.crossover(b);
benchmark::DoNotOptimize(child);
}
}
BENCHMARK(BM_Crossover);