RawSpeed
fast raw decoding library
Loading...
Searching...
No Matches
CameraMetaDataBenchmark.cpp
Go to the documentation of this file.
1/*
2 RawSpeed - RAW file decoder.
3
4 Copyright (C) 2018 Roman Lebedev
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with this library; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19*/
20
21#include "rawspeedconfig.h"
23#include <pugixml.hpp>
24#include <benchmark/benchmark.h>
25
26#ifndef HAVE_PUGIXML
27#error This benchmark requires to be built with pugixml being present.
28#endif
29
30namespace {
31
32constexpr const char* const CAMERASXML =
33 RAWSPEED_SOURCE_DIR "/data/cameras.xml";
34
35void BM_pugixml_load_cameras_xml(benchmark::State& state) {
36 for (auto _ : state) {
37 pugi::xml_document doc;
38
39#if defined(__unix__) || defined(__APPLE__)
40 pugi::xml_parse_result result = doc.load_file(CAMERASXML);
41#else
42 pugi::xml_parse_result result =
43 doc.load_file(pugi::as_wide(CAMERASXML).c_str());
44#endif
45
46 benchmark::DoNotOptimize(doc);
47 benchmark::DoNotOptimize(result);
48 }
49}
50BENCHMARK(BM_pugixml_load_cameras_xml)->Unit(benchmark::kMicrosecond);
51
52void BM_CameraMetaData(benchmark::State& state) {
53 for (auto _ : state) {
55 benchmark::DoNotOptimize(metadata);
56 }
57}
58BENCHMARK(BM_CameraMetaData)->Unit(benchmark::kMicrosecond);
59
60} // namespace
61
BENCHMARK_MAIN()
static const rawspeed::CameraMetaData metadata
Definition main.cpp:54
BENCHMARK(BM_pugixml_load_cameras_xml) -> Unit(benchmark::kMicrosecond)