1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-22 23:23:53 +00:00
openmw/apps/benchmarks/settings/access.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

87 lines
2.2 KiB
C++
Raw Normal View History

2023-02-03 14:30:58 +00:00
#include <benchmark/benchmark.h>
#include <components/files/configurationmanager.hpp>
#include <components/settings/settings.hpp>
#include <components/settings/values.hpp>
#include <boost/program_options.hpp>
#include <algorithm>
#include <iostream>
namespace
{
namespace bpo = boost::program_options;
bpo::options_description makeOptionsDescription()
{
bpo::options_description result;
auto addOption = result.add_options();
addOption("help", "print help message");
Files::ConfigurationManager::addCommonOptions(result);
return result;
}
void settingsManager(benchmark::State& state)
{
for (auto _ : state)
{
benchmark::DoNotOptimize(Settings::Manager::getFloat("sky blending start", "Fog"));
}
}
void localStatic(benchmark::State& state)
{
for (auto _ : state)
{
static const float v = Settings::Manager::getFloat("sky blending start", "Fog");
benchmark::DoNotOptimize(v);
}
}
void settingsStorage(benchmark::State& state)
{
for (auto _ : state)
{
benchmark::DoNotOptimize(Settings::fog().mSkyBlendingStart.get());
}
}
}
BENCHMARK(settingsManager);
BENCHMARK(localStatic);
BENCHMARK(settingsStorage);
int main(int argc, char* argv[])
{
bpo::options_description desc = makeOptionsDescription();
bpo::parsed_options options = bpo::command_line_parser(argc, argv).options(desc).allow_unregistered().run();
bpo::variables_map variables;
bpo::store(options, variables);
bpo::notify(variables);
if (variables.find("help") != variables.end())
{
std::cout << desc << std::endl;
benchmark::Initialize(&argc, argv);
benchmark::Shutdown();
return 1;
}
Files::ConfigurationManager config;
bpo::variables_map composingVariables = Files::separateComposingVariables(variables, desc);
config.readConfiguration(variables, desc);
Files::mergeComposingVariables(variables, composingVariables, desc);
Settings::Manager::load(config);
benchmark::Initialize(&argc, argv);
benchmark::RunSpecifiedBenchmarks();
benchmark::Shutdown();
return 0;
}