Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
32 lines
1.0 KiB
C++
32 lines
1.0 KiB
C++
#include <benchmark/benchmark.h>
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
#include <mbgl/util/color.hpp>
|
|
|
|
static const std::vector<std::string> testStrings = {"#000000",
|
|
"#FFFFFF",
|
|
"#FF00FFAA",
|
|
"rgba(255, 0, 0, 1.0)",
|
|
"rgb(0, 255, 0)",
|
|
"blue",
|
|
"red",
|
|
"invalid-color",
|
|
"rgba(255, 255, 255, 0.5)",
|
|
"#123"};
|
|
|
|
namespace {
|
|
|
|
void ColorParse(benchmark::State& state) {
|
|
for (auto _ : state) {
|
|
for (const auto& str : testStrings) {
|
|
auto result = mln::Color::parse(str);
|
|
benchmark::DoNotOptimize(result);
|
|
}
|
|
}
|
|
}
|
|
|
|
}; // namespace
|
|
|
|
BENCHMARK(ColorParse);
|