1 /*
2 * Copyright (c) 2024 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include <benchmark/benchmark.h>
17 #include <meta_object_initializer.h>
18
19 #include <core/engine_info.h>
20 #include <core/implementation_uids.h>
21 #include <core/intf_engine.h>
22 #include <core/log.h>
23 #include <core/plugin/intf_class_register.h>
24 #include <core/plugin/intf_plugin_register.h>
25
26 #include "utils.h"
27
28 namespace benchmarks {
29
30 class BenchmarkEnvironment {
31 public:
BenchmarkEnvironment()32 BenchmarkEnvironment()
33 {
34 environmentSetup::InitializeMetaObject(".\\AGPEngineDLL.dll", CORE_NS::ILogger::LogLevel::LOG_ERROR);
35
36 CORE_NS::GetPluginRegister().LoadPlugins({}); // load all plugins, do we need this?
37
38 CORE_NS::VersionInfo versInfoEngine {
39 "MetaObject_Benchmark_Runner",
40 0,
41 1,
42 0,
43 };
44 const CORE_NS::EngineCreateInfo engineCreateInfo { { "./", "./", "" }, versInfoEngine, {} };
45
46 auto factory = CORE_NS::GetInstance<CORE_NS::IEngineFactory>(CORE_NS::UID_ENGINE_FACTORY);
47 engine_ = factory->Create(engineCreateInfo);
48 engine_->Init();
49 }
50
~BenchmarkEnvironment()51 ~BenchmarkEnvironment()
52 {
53 engine_.reset();
54 environmentSetup::ShutdownMetaObject();
55 }
56
57 private:
58 CORE_NS::IEngine::Ptr engine_;
59 };
60
61 } // namespace benchmarks
62
main(int argc,char ** argv)63 int main(int argc, char** argv)
64 {
65 const auto environment = benchmarks::BenchmarkEnvironment();
66
67 META_NS::benchmarks::RegisterBenchmarkTypes();
68
69 benchmark::Initialize(&argc, argv);
70 if (::benchmark::ReportUnrecognizedArguments(argc, argv)) {
71 return 1;
72 }
73 benchmark::RunSpecifiedBenchmarks();
74 benchmark::Shutdown();
75
76 META_NS::benchmarks::UnregisterBenchmarkTypes();
77
78 return 0;
79 }
80