1094332d3Sopenharmony_ci/*
2094332d3Sopenharmony_ci * Copyright (c) 2022-2023 Huawei Device Co., Ltd.
3094332d3Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4094332d3Sopenharmony_ci * you may not use this file except in compliance with the License.
5094332d3Sopenharmony_ci * You may obtain a copy of the License at
6094332d3Sopenharmony_ci *
7094332d3Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8094332d3Sopenharmony_ci *
9094332d3Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10094332d3Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11094332d3Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12094332d3Sopenharmony_ci * See the License for the specific language governing permissions and
13094332d3Sopenharmony_ci * limitations under the License.
14094332d3Sopenharmony_ci */
15094332d3Sopenharmony_ci
16094332d3Sopenharmony_ci#include <benchmark/benchmark.h>
17094332d3Sopenharmony_ci#include <cmath>
18094332d3Sopenharmony_ci#include <cstdio>
19094332d3Sopenharmony_ci#include <gtest/gtest.h>
20094332d3Sopenharmony_ci#include <securec.h>
21094332d3Sopenharmony_ci#include <string>
22094332d3Sopenharmony_ci#include <unistd.h>
23094332d3Sopenharmony_ci#include <vector>
24094332d3Sopenharmony_ci#include "hdf_base.h"
25094332d3Sopenharmony_ci#include "osal_time.h"
26094332d3Sopenharmony_ci#include "sensor_callback_impl.h"
27094332d3Sopenharmony_ci#include "sensor_type.h"
28094332d3Sopenharmony_ci#include "sensor_uhdf_log.h"
29094332d3Sopenharmony_ci#include "v2_0/isensor_interface.h"
30094332d3Sopenharmony_ci
31094332d3Sopenharmony_ciusing namespace OHOS::HDI::Sensor::V2_0;
32094332d3Sopenharmony_ciusing namespace testing::ext;
33094332d3Sopenharmony_ciusing namespace std;
34094332d3Sopenharmony_ci
35094332d3Sopenharmony_cinamespace {
36094332d3Sopenharmony_ci    sptr<ISensorInterface>  g_sensorInterface = nullptr;
37094332d3Sopenharmony_ci    sptr<ISensorCallback> g_traditionalCallback = new SensorCallbackImpl();
38094332d3Sopenharmony_ci    sptr<ISensorCallback> g_medicalCallback = new SensorCallbackImpl();
39094332d3Sopenharmony_ci    std::vector<HdfSensorInformation> g_info;
40094332d3Sopenharmony_ci
41094332d3Sopenharmony_ci    constexpr int32_t ITERATION_FREQUENCY = 100;
42094332d3Sopenharmony_ci    constexpr int32_t REPETITION_FREQUENCY = 3;
43094332d3Sopenharmony_ci    constexpr int32_t SENSOR_INTERVAL1 = 20;
44094332d3Sopenharmony_ci    constexpr int32_t SENSOR_INTERVAL2 = 2;
45094332d3Sopenharmony_ci    constexpr int32_t SENSOR_POLL_TIME = 3;
46094332d3Sopenharmony_ci    constexpr int32_t SENSOR_WAIT_TIME = 10;
47094332d3Sopenharmony_ci    constexpr uint32_t OPTION = 0;
48094332d3Sopenharmony_ci    constexpr uint32_t SENSOR_DATA_FLAG = 1;
49094332d3Sopenharmony_ci
50094332d3Sopenharmony_ciclass SensorBenchmarkTest : public benchmark::Fixture {
51094332d3Sopenharmony_cipublic:
52094332d3Sopenharmony_ci    void SetUp(const ::benchmark::State &state);
53094332d3Sopenharmony_ci    void TearDown(const ::benchmark::State &state);
54094332d3Sopenharmony_ci};
55094332d3Sopenharmony_ci
56094332d3Sopenharmony_civoid SensorBenchmarkTest::SetUp(const ::benchmark::State &state)
57094332d3Sopenharmony_ci{
58094332d3Sopenharmony_ci    g_sensorInterface = ISensorInterface::Get();
59094332d3Sopenharmony_ci}
60094332d3Sopenharmony_ci
61094332d3Sopenharmony_civoid SensorBenchmarkTest::TearDown(const ::benchmark::State &state)
62094332d3Sopenharmony_ci{
63094332d3Sopenharmony_ci}
64094332d3Sopenharmony_ci
65094332d3Sopenharmony_ci/**
66094332d3Sopenharmony_ci  * @tc.name: DriverSystem_SensorBenchmark_GetAllSensorInfo
67094332d3Sopenharmony_ci  * @tc.desc: Benchmarktest for interface GetAllSensorInfo
68094332d3Sopenharmony_ci  * Obtains information about all sensors in the system
69094332d3Sopenharmony_ci  * @tc.type: FUNC
70094332d3Sopenharmony_ci  */
71094332d3Sopenharmony_ciBENCHMARK_F(SensorBenchmarkTest, GetAllSensorInfo)(benchmark::State &state)
72094332d3Sopenharmony_ci{
73094332d3Sopenharmony_ci    ASSERT_NE(nullptr, g_sensorInterface);
74094332d3Sopenharmony_ci
75094332d3Sopenharmony_ci    int32_t ret;
76094332d3Sopenharmony_ci
77094332d3Sopenharmony_ci    for (auto _ : state) {
78094332d3Sopenharmony_ci        ret = g_sensorInterface->GetAllSensorInfo(g_info);
79094332d3Sopenharmony_ci        EXPECT_EQ(SENSOR_SUCCESS, ret);
80094332d3Sopenharmony_ci    }
81094332d3Sopenharmony_ci}
82094332d3Sopenharmony_ci
83094332d3Sopenharmony_ciBENCHMARK_REGISTER_F(SensorBenchmarkTest, GetAllSensorInfo)->
84094332d3Sopenharmony_ci    Iterations(ITERATION_FREQUENCY)->Repetitions(REPETITION_FREQUENCY)->ReportAggregatesOnly();
85094332d3Sopenharmony_ci
86094332d3Sopenharmony_ci/**
87094332d3Sopenharmony_ci  * @tc.name: DriverSystem_SensorBenchmark_register
88094332d3Sopenharmony_ci  * @tc.desc: Benchmarktest for interface register
89094332d3Sopenharmony_ci  * Returns 0 if the callback is successfully registered; returns a negative value otherwise
90094332d3Sopenharmony_ci  * @tc.type: FUNC
91094332d3Sopenharmony_ci  */
92094332d3Sopenharmony_ciBENCHMARK_F(SensorBenchmarkTest, register)(benchmark::State &state)
93094332d3Sopenharmony_ci{
94094332d3Sopenharmony_ci    ASSERT_NE(nullptr, g_sensorInterface);
95094332d3Sopenharmony_ci
96094332d3Sopenharmony_ci    int32_t ret;
97094332d3Sopenharmony_ci
98094332d3Sopenharmony_ci    for (auto _ : state) {
99094332d3Sopenharmony_ci        ret = g_sensorInterface->Register(TRADITIONAL_SENSOR_TYPE, g_traditionalCallback);
100094332d3Sopenharmony_ci        EXPECT_EQ(SENSOR_SUCCESS, ret);
101094332d3Sopenharmony_ci    }
102094332d3Sopenharmony_ci    ret = g_sensorInterface->Unregister(TRADITIONAL_SENSOR_TYPE, g_traditionalCallback);
103094332d3Sopenharmony_ci    EXPECT_EQ(SENSOR_SUCCESS, ret);
104094332d3Sopenharmony_ci}
105094332d3Sopenharmony_ci
106094332d3Sopenharmony_ciBENCHMARK_REGISTER_F(SensorBenchmarkTest, register)->
107094332d3Sopenharmony_ci    Iterations(ITERATION_FREQUENCY)->Repetitions(REPETITION_FREQUENCY)->ReportAggregatesOnly();
108094332d3Sopenharmony_ci
109094332d3Sopenharmony_ci/**
110094332d3Sopenharmony_ci  * @tc.name: DriverSystem_SensorBenchmark_Unregister
111094332d3Sopenharmony_ci  * @tc.desc: Benchmarktest for interface Unregister
112094332d3Sopenharmony_ci  * Returns 0 if the callback is successfully registered; returns a negative value otherwise
113094332d3Sopenharmony_ci  * @tc.type: FUNC
114094332d3Sopenharmony_ci  */
115094332d3Sopenharmony_ciBENCHMARK_F(SensorBenchmarkTest, Unregister)(benchmark::State &state)
116094332d3Sopenharmony_ci{
117094332d3Sopenharmony_ci    ASSERT_NE(nullptr, g_sensorInterface);
118094332d3Sopenharmony_ci
119094332d3Sopenharmony_ci    int32_t ret;
120094332d3Sopenharmony_ci
121094332d3Sopenharmony_ci    for (auto _ : state) {
122094332d3Sopenharmony_ci        ret = g_sensorInterface->Register(TRADITIONAL_SENSOR_TYPE, g_traditionalCallback);
123094332d3Sopenharmony_ci        OsalMSleep(SENSOR_POLL_TIME);
124094332d3Sopenharmony_ci        EXPECT_EQ(SENSOR_SUCCESS, ret);
125094332d3Sopenharmony_ci        ret = g_sensorInterface->Unregister(TRADITIONAL_SENSOR_TYPE, g_traditionalCallback);
126094332d3Sopenharmony_ci        OsalMSleep(SENSOR_POLL_TIME);
127094332d3Sopenharmony_ci        EXPECT_EQ(SENSOR_SUCCESS, ret);
128094332d3Sopenharmony_ci    }
129094332d3Sopenharmony_ci}
130094332d3Sopenharmony_ci
131094332d3Sopenharmony_ciBENCHMARK_REGISTER_F(SensorBenchmarkTest, Unregister)->
132094332d3Sopenharmony_ci    Iterations(ITERATION_FREQUENCY)->Repetitions(REPETITION_FREQUENCY)->ReportAggregatesOnly();
133094332d3Sopenharmony_ci
134094332d3Sopenharmony_ci/**
135094332d3Sopenharmony_ci  * @tc.name: DriverSystem_SensorBenchmark_Enable
136094332d3Sopenharmony_ci  * @tc.desc: Benchmarktest for interface Enable
137094332d3Sopenharmony_ci  * Enables the sensor unavailable in the sensor list based on the specified sensor ID
138094332d3Sopenharmony_ci  * @tc.type: FUNC
139094332d3Sopenharmony_ci  */
140094332d3Sopenharmony_ciBENCHMARK_F(SensorBenchmarkTest, Enable)(benchmark::State &state)
141094332d3Sopenharmony_ci{
142094332d3Sopenharmony_ci    ASSERT_NE(nullptr, g_sensorInterface);
143094332d3Sopenharmony_ci
144094332d3Sopenharmony_ci    int32_t ret;
145094332d3Sopenharmony_ci
146094332d3Sopenharmony_ci    ret = g_sensorInterface->Register(TRADITIONAL_SENSOR_TYPE, g_traditionalCallback);
147094332d3Sopenharmony_ci    EXPECT_EQ(SENSOR_SUCCESS, ret);
148094332d3Sopenharmony_ci
149094332d3Sopenharmony_ci    EXPECT_GT(g_info.size(), 0);
150094332d3Sopenharmony_ci
151094332d3Sopenharmony_ci    for (auto iter : g_info) {
152094332d3Sopenharmony_ci        HDF_LOGI("get sensoriId[%{public}d], info name[%{public}s], power[%{public}f]\n\r",
153094332d3Sopenharmony_ci            iter.sensorId, iter.sensorName.c_str(), iter.power);
154094332d3Sopenharmony_ci        ret = g_sensorInterface->SetBatch(iter.sensorId, SENSOR_INTERVAL1, SENSOR_POLL_TIME);
155094332d3Sopenharmony_ci        EXPECT_EQ(SENSOR_SUCCESS, ret);
156094332d3Sopenharmony_ci        for (auto _ : state) {
157094332d3Sopenharmony_ci            ret = g_sensorInterface->Enable(iter.sensorId);
158094332d3Sopenharmony_ci            EXPECT_EQ(SENSOR_SUCCESS, ret);
159094332d3Sopenharmony_ci        }
160094332d3Sopenharmony_ci        OsalMSleep(SENSOR_POLL_TIME);
161094332d3Sopenharmony_ci        ret = g_sensorInterface->Disable(iter.sensorId);
162094332d3Sopenharmony_ci        EXPECT_EQ(SENSOR_SUCCESS, ret);
163094332d3Sopenharmony_ci    }
164094332d3Sopenharmony_ci    ret = g_sensorInterface->Unregister(TRADITIONAL_SENSOR_TYPE, g_traditionalCallback);
165094332d3Sopenharmony_ci    EXPECT_EQ(SensorCallbackImpl::sensorDataFlag, SENSOR_DATA_FLAG);
166094332d3Sopenharmony_ci    SensorCallbackImpl::sensorDataFlag = SENSOR_DATA_FLAG;
167094332d3Sopenharmony_ci}
168094332d3Sopenharmony_ci
169094332d3Sopenharmony_ciBENCHMARK_REGISTER_F(SensorBenchmarkTest, Enable)->
170094332d3Sopenharmony_ci    Iterations(ITERATION_FREQUENCY)->Repetitions(REPETITION_FREQUENCY)->ReportAggregatesOnly();
171094332d3Sopenharmony_ci
172094332d3Sopenharmony_ci/**
173094332d3Sopenharmony_ci  * @tc.name: DriverSystem_SensorBenchmark_Disable
174094332d3Sopenharmony_ci  * @tc.desc: Benchmarktest for interface Disable
175094332d3Sopenharmony_ci  * Enables the sensor unavailable in the sensor list based on the specified sensor ID
176094332d3Sopenharmony_ci  * @tc.type: FUNC
177094332d3Sopenharmony_ci  */
178094332d3Sopenharmony_ciBENCHMARK_F(SensorBenchmarkTest, Disable)(benchmark::State &state)
179094332d3Sopenharmony_ci{
180094332d3Sopenharmony_ci    ASSERT_NE(nullptr, g_sensorInterface);
181094332d3Sopenharmony_ci
182094332d3Sopenharmony_ci    int32_t ret;
183094332d3Sopenharmony_ci
184094332d3Sopenharmony_ci    ret = g_sensorInterface->Register(TRADITIONAL_SENSOR_TYPE, g_traditionalCallback);
185094332d3Sopenharmony_ci    EXPECT_EQ(SENSOR_SUCCESS, ret);
186094332d3Sopenharmony_ci    EXPECT_GT(g_info.size(), 0);
187094332d3Sopenharmony_ci
188094332d3Sopenharmony_ci    for (auto iter : g_info) {
189094332d3Sopenharmony_ci        HDF_LOGI("get sensoriId[%{public}d], info name[%{public}s], power[%{public}f]\n\r",
190094332d3Sopenharmony_ci            iter.sensorId, iter.sensorName.c_str(), iter.power);
191094332d3Sopenharmony_ci        ret = g_sensorInterface->SetBatch(iter.sensorId, SENSOR_INTERVAL1, SENSOR_POLL_TIME);
192094332d3Sopenharmony_ci        EXPECT_EQ(SENSOR_SUCCESS, ret);
193094332d3Sopenharmony_ci        ret = g_sensorInterface->Enable(iter.sensorId);
194094332d3Sopenharmony_ci        EXPECT_EQ(SENSOR_SUCCESS, ret);
195094332d3Sopenharmony_ci        OsalMSleep(SENSOR_POLL_TIME);
196094332d3Sopenharmony_ci        for (auto _ : state) {
197094332d3Sopenharmony_ci            ret = g_sensorInterface->Disable(iter.sensorId);
198094332d3Sopenharmony_ci            EXPECT_EQ(SENSOR_SUCCESS, ret);
199094332d3Sopenharmony_ci        }
200094332d3Sopenharmony_ci    }
201094332d3Sopenharmony_ci    ret = g_sensorInterface->Unregister(TRADITIONAL_SENSOR_TYPE, g_traditionalCallback);
202094332d3Sopenharmony_ci    EXPECT_EQ(SensorCallbackImpl::sensorDataFlag, SENSOR_DATA_FLAG);
203094332d3Sopenharmony_ci    SensorCallbackImpl::sensorDataFlag = SENSOR_DATA_FLAG;
204094332d3Sopenharmony_ci}
205094332d3Sopenharmony_ci
206094332d3Sopenharmony_ciBENCHMARK_REGISTER_F(SensorBenchmarkTest, Disable)->
207094332d3Sopenharmony_ci    Iterations(ITERATION_FREQUENCY)->Repetitions(REPETITION_FREQUENCY)->ReportAggregatesOnly();
208094332d3Sopenharmony_ci
209094332d3Sopenharmony_ci/**
210094332d3Sopenharmony_ci  * @tc.name: DriverSystem_SensorBenchmark_SetBatch
211094332d3Sopenharmony_ci  * @tc.desc: Benchmarktest for interface SetBatch
212094332d3Sopenharmony_ci  * Sets the sampling time and data report interval for sensors in batches
213094332d3Sopenharmony_ci  * @tc.type: FUNC
214094332d3Sopenharmony_ci  */
215094332d3Sopenharmony_ciBENCHMARK_F(SensorBenchmarkTest, SetBatch)(benchmark::State &state)
216094332d3Sopenharmony_ci{
217094332d3Sopenharmony_ci    ASSERT_NE(nullptr, g_sensorInterface);
218094332d3Sopenharmony_ci
219094332d3Sopenharmony_ci    int32_t ret;
220094332d3Sopenharmony_ci
221094332d3Sopenharmony_ci    ret = g_sensorInterface->Register(TRADITIONAL_SENSOR_TYPE, g_traditionalCallback);
222094332d3Sopenharmony_ci    EXPECT_EQ(SENSOR_SUCCESS, ret);
223094332d3Sopenharmony_ci
224094332d3Sopenharmony_ci    EXPECT_GT(g_info.size(), 0);
225094332d3Sopenharmony_ci    for (auto iter : g_info) {
226094332d3Sopenharmony_ci        HDF_LOGI("get sensoriId[%{public}d], info name[%{public}s], power[%{public}f]\n\r",
227094332d3Sopenharmony_ci            iter.sensorId, iter.sensorName.c_str(), iter.power);
228094332d3Sopenharmony_ci        for (auto _ : state) {
229094332d3Sopenharmony_ci            ret = g_sensorInterface->SetBatch(iter.sensorId, SENSOR_INTERVAL2, SENSOR_POLL_TIME);
230094332d3Sopenharmony_ci            EXPECT_EQ(SENSOR_SUCCESS, ret);
231094332d3Sopenharmony_ci        }
232094332d3Sopenharmony_ci        ret = g_sensorInterface->Enable(iter.sensorId);
233094332d3Sopenharmony_ci        EXPECT_EQ(SENSOR_SUCCESS, ret);
234094332d3Sopenharmony_ci        OsalMSleep(SENSOR_WAIT_TIME);
235094332d3Sopenharmony_ci        ret = g_sensorInterface->Disable(iter.sensorId);
236094332d3Sopenharmony_ci        EXPECT_EQ(SENSOR_SUCCESS, ret);
237094332d3Sopenharmony_ci    }
238094332d3Sopenharmony_ci    ret = g_sensorInterface->Unregister(TRADITIONAL_SENSOR_TYPE, g_traditionalCallback);
239094332d3Sopenharmony_ci    EXPECT_EQ(SENSOR_SUCCESS, ret);
240094332d3Sopenharmony_ci    EXPECT_EQ(SensorCallbackImpl::sensorDataFlag, SENSOR_DATA_FLAG);
241094332d3Sopenharmony_ci    SensorCallbackImpl::sensorDataFlag = SENSOR_DATA_FLAG;
242094332d3Sopenharmony_ci}
243094332d3Sopenharmony_ci
244094332d3Sopenharmony_ciBENCHMARK_REGISTER_F(SensorBenchmarkTest, SetBatch)->
245094332d3Sopenharmony_ci    Iterations(ITERATION_FREQUENCY)->Repetitions(REPETITION_FREQUENCY)->ReportAggregatesOnly();
246094332d3Sopenharmony_ci
247094332d3Sopenharmony_ci/**
248094332d3Sopenharmony_ci  * @tc.name: DriverSystem_SensorBenchmark_SetMode
249094332d3Sopenharmony_ci  * @tc.desc: Benchmarktest for interface SetMode
250094332d3Sopenharmony_ci  * Sets the data reporting mode for the specified sensor
251094332d3Sopenharmony_ci  * @tc.type: FUNC
252094332d3Sopenharmony_ci  */
253094332d3Sopenharmony_ciBENCHMARK_F(SensorBenchmarkTest, SetMode)(benchmark::State &state)
254094332d3Sopenharmony_ci{
255094332d3Sopenharmony_ci    ASSERT_NE(nullptr, g_sensorInterface);
256094332d3Sopenharmony_ci    EXPECT_GT(g_info.size(), 0);
257094332d3Sopenharmony_ci
258094332d3Sopenharmony_ci    int32_t ret;
259094332d3Sopenharmony_ci    EXPECT_GT(g_info.size(), 0);
260094332d3Sopenharmony_ci    for (auto iter : g_info) {
261094332d3Sopenharmony_ci        HDF_LOGI("get sensoriId[%{public}d], info name[%{public}s], power[%{public}f]\n\r",
262094332d3Sopenharmony_ci            iter.sensorId, iter.sensorName.c_str(), iter.power);
263094332d3Sopenharmony_ci        ret = g_sensorInterface->SetBatch(iter.sensorId, SENSOR_INTERVAL1, SENSOR_POLL_TIME);
264094332d3Sopenharmony_ci        EXPECT_EQ(SENSOR_SUCCESS, ret);
265094332d3Sopenharmony_ci        for (auto _ : state) {
266094332d3Sopenharmony_ci            if (SENSOR_TYPE_HALL == 0) {
267094332d3Sopenharmony_ci                ret = g_sensorInterface->SetMode(iter.sensorId, SENSOR_MODE_ON_CHANGE);
268094332d3Sopenharmony_ci            } else {
269094332d3Sopenharmony_ci                ret = g_sensorInterface->SetMode(iter.sensorId, SENSOR_MODE_REALTIME);
270094332d3Sopenharmony_ci            }
271094332d3Sopenharmony_ci            EXPECT_EQ(SENSOR_SUCCESS, ret);
272094332d3Sopenharmony_ci        }
273094332d3Sopenharmony_ci        ret = g_sensorInterface->Enable(iter.sensorId);
274094332d3Sopenharmony_ci        EXPECT_EQ(SENSOR_SUCCESS, ret);
275094332d3Sopenharmony_ci        OsalMSleep(SENSOR_WAIT_TIME);
276094332d3Sopenharmony_ci        ret = g_sensorInterface->Disable(iter.sensorId);
277094332d3Sopenharmony_ci        EXPECT_EQ(SENSOR_SUCCESS, ret);
278094332d3Sopenharmony_ci    }
279094332d3Sopenharmony_ci}
280094332d3Sopenharmony_ci
281094332d3Sopenharmony_ciBENCHMARK_REGISTER_F(SensorBenchmarkTest, SetMode)->
282094332d3Sopenharmony_ci    Iterations(ITERATION_FREQUENCY)->Repetitions(REPETITION_FREQUENCY)->ReportAggregatesOnly();
283094332d3Sopenharmony_ci
284094332d3Sopenharmony_ci/**
285094332d3Sopenharmony_ci  * @tc.name: DriverSystem_SensorBenchmark_SetOption
286094332d3Sopenharmony_ci  * @tc.desc: Benchmarktest for interface SetOption
287094332d3Sopenharmony_ci  * Sets options for the specified sensor, including its measurement range and accuracy
288094332d3Sopenharmony_ci  * @tc.type: FUNC
289094332d3Sopenharmony_ci  */
290094332d3Sopenharmony_ciBENCHMARK_F(SensorBenchmarkTest, SetOption)(benchmark::State &state)
291094332d3Sopenharmony_ci{
292094332d3Sopenharmony_ci    ASSERT_NE(nullptr, g_sensorInterface);
293094332d3Sopenharmony_ci    EXPECT_GT(g_info.size(), 0);
294094332d3Sopenharmony_ci
295094332d3Sopenharmony_ci    int32_t ret;
296094332d3Sopenharmony_ci    EXPECT_GT(g_info.size(), 0);
297094332d3Sopenharmony_ci    for (auto iter : g_info) {
298094332d3Sopenharmony_ci        HDF_LOGI("get sensoriId[%{public}d], info name[%{public}s], power[%{public}f]\n\r",
299094332d3Sopenharmony_ci            iter.sensorId, iter.sensorName.c_str(), iter.power);
300094332d3Sopenharmony_ci        for (auto _ : state) {
301094332d3Sopenharmony_ci            ret = g_sensorInterface->SetOption(iter.sensorId, OPTION);
302094332d3Sopenharmony_ci            EXPECT_EQ(SENSOR_SUCCESS, ret);
303094332d3Sopenharmony_ci        }
304094332d3Sopenharmony_ci    }
305094332d3Sopenharmony_ci}
306094332d3Sopenharmony_ci
307094332d3Sopenharmony_ciBENCHMARK_REGISTER_F(SensorBenchmarkTest, SetOption)->
308094332d3Sopenharmony_ci    Iterations(ITERATION_FREQUENCY)->Repetitions(REPETITION_FREQUENCY)->ReportAggregatesOnly();
309094332d3Sopenharmony_ci}
310094332d3Sopenharmony_ci
311094332d3Sopenharmony_ciBENCHMARK_MAIN();
312