19762338dSopenharmony_ci/* 29762338dSopenharmony_ci * Copyright (c) 2022-2024 Huawei Device Co., Ltd. 39762338dSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 49762338dSopenharmony_ci * you may not use this file except in compliance with the License. 59762338dSopenharmony_ci * You may obtain a copy of the License at 69762338dSopenharmony_ci * 79762338dSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 89762338dSopenharmony_ci * 99762338dSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 109762338dSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 119762338dSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 129762338dSopenharmony_ci * See the License for the specific language governing permissions and 139762338dSopenharmony_ci * limitations under the License. 149762338dSopenharmony_ci */ 159762338dSopenharmony_ci#include <iostream> 169762338dSopenharmony_ci#include <string> 179762338dSopenharmony_ci#include <vector> 189762338dSopenharmony_ci 199762338dSopenharmony_ci#include "HdfUsbdBenchmarkTransferTest.h" 209762338dSopenharmony_ci#include "hdf_log.h" 219762338dSopenharmony_ci#include "securec.h" 229762338dSopenharmony_ci#include "v1_1/iusb_interface.h" 239762338dSopenharmony_ci 249762338dSopenharmony_ciusing namespace benchmark::internal; 259762338dSopenharmony_ciusing namespace OHOS; 269762338dSopenharmony_ciusing namespace OHOS::USB; 279762338dSopenharmony_ciusing namespace std; 289762338dSopenharmony_ciusing namespace OHOS::HDI::Usb::V1_0; 299762338dSopenharmony_ciusing namespace OHOS::HDI::Usb::V1_1; 309762338dSopenharmony_ci 319762338dSopenharmony_ciconst int SLEEP_TIME = 3; 329762338dSopenharmony_ciconst uint32_t MAX_BUFFER_LENGTH = 255; 339762338dSopenharmony_ciconst uint8_t INTERFACEID_OK = 1; 349762338dSopenharmony_ci// data interface have 2 point : 1->bulk_out 2->bulk_in 359762338dSopenharmony_ciconst uint8_t POINTID_BULK_IN = USB_ENDPOINT_DIR_IN | 2; 369762338dSopenharmony_ciconst uint8_t POINTID_BULK_OUT = USB_ENDPOINT_DIR_OUT | 1; 379762338dSopenharmony_ciconst int32_t ASHMEM_MAX_SIZE = 1024; 389762338dSopenharmony_ciconst uint8_t SAMPLE_DATA_1 = 1; 399762338dSopenharmony_ciconst uint8_t SAMPLE_DATA_2 = 2; 409762338dSopenharmony_ciconst uint8_t SAMPLE_DATA_3 = 3; 419762338dSopenharmony_ciconst int32_t TRANSFER_TIME_OUT = 1000; 429762338dSopenharmony_ciconstexpr int32_t ITERATION_FREQUENCY = 100; 439762338dSopenharmony_ciconstexpr int32_t REPETITION_FREQUENCY = 3; 449762338dSopenharmony_ciUsbDev HdfUsbdBenchmarkTransferTest::dev_ = { 0, 0 }; 459762338dSopenharmony_ci 469762338dSopenharmony_cinamespace { 479762338dSopenharmony_cisptr<OHOS::HDI::Usb::V1_1::IUsbInterface> g_usbInterface = nullptr; 489762338dSopenharmony_ci 499762338dSopenharmony_ciint32_t InitAshmemOne(sptr<Ashmem>& asmptr, int32_t asmSize, uint8_t rflg) 509762338dSopenharmony_ci{ 519762338dSopenharmony_ci asmptr = Ashmem::CreateAshmem("ttashmem000", asmSize); 529762338dSopenharmony_ci if (asmptr == nullptr) { 539762338dSopenharmony_ci return HDF_FAILURE; 549762338dSopenharmony_ci } 559762338dSopenharmony_ci 569762338dSopenharmony_ci asmptr->MapReadAndWriteAshmem(); 579762338dSopenharmony_ci 589762338dSopenharmony_ci if (rflg == 0) { 599762338dSopenharmony_ci uint8_t tdata[ASHMEM_MAX_SIZE]; 609762338dSopenharmony_ci int32_t offset = 0; 619762338dSopenharmony_ci int32_t tlen = 0; 629762338dSopenharmony_ci 639762338dSopenharmony_ci int32_t retSafe = memset_s(tdata, sizeof(tdata), 'Y', ASHMEM_MAX_SIZE); 649762338dSopenharmony_ci if (retSafe != EOK) { 659762338dSopenharmony_ci return HDF_FAILURE; 669762338dSopenharmony_ci } 679762338dSopenharmony_ci while (offset < asmSize) { 689762338dSopenharmony_ci tlen = (asmSize - offset) < ASHMEM_MAX_SIZE ? (asmSize - offset) : ASHMEM_MAX_SIZE; 699762338dSopenharmony_ci asmptr->WriteToAshmem(tdata, tlen, offset); 709762338dSopenharmony_ci offset += tlen; 719762338dSopenharmony_ci } 729762338dSopenharmony_ci } 739762338dSopenharmony_ci return HDF_SUCCESS; 749762338dSopenharmony_ci} 759762338dSopenharmony_ci 769762338dSopenharmony_ciint32_t SwitchErrCode(int32_t ret) 779762338dSopenharmony_ci{ 789762338dSopenharmony_ci return ret == HDF_ERR_NOT_SUPPORT ? HDF_SUCCESS : ret; 799762338dSopenharmony_ci} 809762338dSopenharmony_ci 819762338dSopenharmony_civoid HdfUsbdBenchmarkTransferTest::SetUp(const ::benchmark::State& state) 829762338dSopenharmony_ci{ 839762338dSopenharmony_ci g_usbInterface = OHOS::HDI::Usb::V1_1::IUsbInterface::Get(); 849762338dSopenharmony_ci ASSERT_NE(g_usbInterface, nullptr); 859762338dSopenharmony_ci auto ret = g_usbInterface->SetPortRole(DEFAULT_PORT_ID, POWER_ROLE_SOURCE, DATA_ROLE_HOST); 869762338dSopenharmony_ci sleep(SLEEP_TIME); 879762338dSopenharmony_ci ret = SwitchErrCode(ret); 889762338dSopenharmony_ci ASSERT_EQ(0, ret); 899762338dSopenharmony_ci} 909762338dSopenharmony_ci 919762338dSopenharmony_civoid HdfUsbdBenchmarkTransferTest::TearDown(const ::benchmark::State& state){} 929762338dSopenharmony_ci 939762338dSopenharmony_civoid HdfUsbdBenchmarkTransferTest::InitPara(const sptr<UsbSubscriberTest> &subscriber) 949762338dSopenharmony_ci{ 959762338dSopenharmony_ci auto ret = g_usbInterface->BindUsbdSubscriber(subscriber); 969762338dSopenharmony_ci ASSERT_EQ(0, ret); 979762338dSopenharmony_ci dev_ = {subscriber->busNum_, subscriber->devAddr_}; 989762338dSopenharmony_ci ret = g_usbInterface->OpenDevice(dev_); 999762338dSopenharmony_ci ASSERT_EQ(0, ret); 1009762338dSopenharmony_ci} 1019762338dSopenharmony_ci 1029762338dSopenharmony_civoid HdfUsbdBenchmarkTransferTest::ReleasePara(const sptr<UsbSubscriberTest> &subscriber) 1039762338dSopenharmony_ci{ 1049762338dSopenharmony_ci ASSERT_TRUE(g_usbInterface != nullptr); 1059762338dSopenharmony_ci auto ret = g_usbInterface->UnbindUsbdSubscriber(subscriber); 1069762338dSopenharmony_ci EXPECT_EQ(0, ret); 1079762338dSopenharmony_ci ret = g_usbInterface->CloseDevice(dev_); 1089762338dSopenharmony_ci ASSERT_EQ(0, ret); 1099762338dSopenharmony_ci} 1109762338dSopenharmony_ci 1119762338dSopenharmony_ci/** 1129762338dSopenharmony_ci * @tc.name: SUB_USB_HostManager_HDI_Performance_1300 1139762338dSopenharmony_ci * @tc.desc: Benchmark test 1149762338dSopenharmony_ci * @tc.desc: Test functions to ControlTransferRead(const UsbDev &dev, UsbCtrlTransfer &ctrl, 1159762338dSopenharmony_ci * std::vector<uint8_t> &data); 1169762338dSopenharmony_ci * @tc.desc: Positive test: parameters correctly, standard request: get configuration 1179762338dSopenharmony_ci * @tc.type: FUNC 1189762338dSopenharmony_ci */ 1199762338dSopenharmony_ciBENCHMARK_F(HdfUsbdBenchmarkTransferTest, SUB_USB_HostManager_HDI_Performance_1300) 1209762338dSopenharmony_ci(benchmark::State& st) 1219762338dSopenharmony_ci{ 1229762338dSopenharmony_ci ASSERT_TRUE(g_usbInterface != nullptr); 1239762338dSopenharmony_ci sptr<UsbSubscriberTest> subscriber = new UsbSubscriberTest(); 1249762338dSopenharmony_ci ASSERT_TRUE(subscriber != nullptr); 1259762338dSopenharmony_ci InitPara(subscriber); 1269762338dSopenharmony_ci struct UsbDev dev = dev_; 1279762338dSopenharmony_ci std::vector<uint8_t> bufferData(MAX_BUFFER_LENGTH); 1289762338dSopenharmony_ci struct UsbCtrlTransfer ctrlparmas = {USB_ENDPOINT_DIR_IN, USB_DDK_REQ_GET_CONFIGURATION, 0, 0, TRANSFER_TIME_OUT}; 1299762338dSopenharmony_ci auto ret = -1; 1309762338dSopenharmony_ci for (auto _ : st) { 1319762338dSopenharmony_ci ret = g_usbInterface->ControlTransferRead(dev, ctrlparmas, bufferData); 1329762338dSopenharmony_ci } 1339762338dSopenharmony_ci ASSERT_EQ(0, ret); 1349762338dSopenharmony_ci ReleasePara(subscriber); 1359762338dSopenharmony_ci} 1369762338dSopenharmony_ci 1379762338dSopenharmony_ciBENCHMARK_REGISTER_F(HdfUsbdBenchmarkTransferTest, SUB_USB_HostManager_HDI_Performance_1300) 1389762338dSopenharmony_ci ->Iterations(ITERATION_FREQUENCY) 1399762338dSopenharmony_ci ->Repetitions(REPETITION_FREQUENCY) 1409762338dSopenharmony_ci ->ReportAggregatesOnly(); 1419762338dSopenharmony_ci 1429762338dSopenharmony_ci/** 1439762338dSopenharmony_ci * @tc.name: SUB_USB_HostManager_HDI_Performance_2000 1449762338dSopenharmony_ci * @tc.desc: Benchmark test 1459762338dSopenharmony_ci * @tc.desc: Test functions to ControlTransferWrite(const UsbDev &dev, UsbCtrlTransfer &ctrl, 1469762338dSopenharmony_ci * std::vector<uint8_t> &data); 1479762338dSopenharmony_ci * @tc.desc: Positive test: parameters correctly 1489762338dSopenharmony_ci * @tc.type: FUNC 1499762338dSopenharmony_ci */ 1509762338dSopenharmony_ciBENCHMARK_F(HdfUsbdBenchmarkTransferTest, SUB_USB_HostManager_HDI_Performance_2000) 1519762338dSopenharmony_ci(benchmark::State& st) 1529762338dSopenharmony_ci{ 1539762338dSopenharmony_ci ASSERT_TRUE(g_usbInterface != nullptr); 1549762338dSopenharmony_ci sptr<UsbSubscriberTest> subscriber = new UsbSubscriberTest(); 1559762338dSopenharmony_ci ASSERT_TRUE(subscriber != nullptr); 1569762338dSopenharmony_ci InitPara(subscriber); 1579762338dSopenharmony_ci struct UsbDev dev = dev_; 1589762338dSopenharmony_ci std::vector<uint8_t> bufferData(MAX_BUFFER_LENGTH); 1599762338dSopenharmony_ci bufferData.push_back(SAMPLE_DATA_1); 1609762338dSopenharmony_ci bufferData.push_back(SAMPLE_DATA_2); 1619762338dSopenharmony_ci bufferData.push_back(SAMPLE_DATA_3); 1629762338dSopenharmony_ci struct UsbCtrlTransfer ctrlparmas = {USB_ENDPOINT_DIR_OUT, 1639762338dSopenharmony_ci USB_DDK_REQ_GET_CONFIGURATION, 0, 0, TRANSFER_TIME_OUT}; 1649762338dSopenharmony_ci auto ret = -1; 1659762338dSopenharmony_ci for (auto _ : st) { 1669762338dSopenharmony_ci ret = g_usbInterface->ControlTransferWrite(dev, ctrlparmas, bufferData); 1679762338dSopenharmony_ci } 1689762338dSopenharmony_ci ASSERT_EQ(0, ret); 1699762338dSopenharmony_ci ReleasePara(subscriber); 1709762338dSopenharmony_ci} 1719762338dSopenharmony_ci 1729762338dSopenharmony_ciBENCHMARK_REGISTER_F(HdfUsbdBenchmarkTransferTest, SUB_USB_HostManager_HDI_Performance_2000) 1739762338dSopenharmony_ci ->Iterations(ITERATION_FREQUENCY) 1749762338dSopenharmony_ci ->Repetitions(REPETITION_FREQUENCY) 1759762338dSopenharmony_ci ->ReportAggregatesOnly(); 1769762338dSopenharmony_ci 1779762338dSopenharmony_ci/** 1789762338dSopenharmony_ci * @tc.name: SUB_USB_HostManager_HDI_Performance_1400 1799762338dSopenharmony_ci * @tc.desc: Benchmark test 1809762338dSopenharmony_ci * @tc.desc: Test functions to BulkTransferRead(const UsbDev &dev, const UsbPipe &pipe, int32_t timeout, 1819762338dSopenharmony_ci * std::vector<uint8_t> &data); 1829762338dSopenharmony_ci * @tc.desc: Positive test: parameters correctly 1839762338dSopenharmony_ci * @tc.type: FUNC 1849762338dSopenharmony_ci */ 1859762338dSopenharmony_ciBENCHMARK_F(HdfUsbdBenchmarkTransferTest, SUB_USB_HostManager_HDI_Performance_1400) 1869762338dSopenharmony_ci(benchmark::State& st) 1879762338dSopenharmony_ci{ 1889762338dSopenharmony_ci ASSERT_TRUE(g_usbInterface != nullptr); 1899762338dSopenharmony_ci sptr<UsbSubscriberTest> subscriber = new UsbSubscriberTest(); 1909762338dSopenharmony_ci ASSERT_TRUE(subscriber != nullptr); 1919762338dSopenharmony_ci InitPara(subscriber); 1929762338dSopenharmony_ci struct UsbDev dev = dev_; 1939762338dSopenharmony_ci uint8_t interfaceId = INTERFACEID_OK; 1949762338dSopenharmony_ci uint8_t pointId = POINTID_BULK_IN; 1959762338dSopenharmony_ci auto ret = g_usbInterface->ClaimInterface(dev, interfaceId, 1); 1969762338dSopenharmony_ci ASSERT_EQ(0, ret); 1979762338dSopenharmony_ci OHOS::HDI::Usb::V1_0::UsbPipe pipe = { interfaceId, pointId }; 1989762338dSopenharmony_ci std::vector<uint8_t> bufferData(MAX_BUFFER_LENGTH); 1999762338dSopenharmony_ci for (auto _ : st) { 2009762338dSopenharmony_ci ret = g_usbInterface->BulkTransferRead(dev, pipe, TRANSFER_TIME_OUT, bufferData); 2019762338dSopenharmony_ci } 2029762338dSopenharmony_ci ASSERT_EQ(0, ret); 2039762338dSopenharmony_ci ReleasePara(subscriber); 2049762338dSopenharmony_ci} 2059762338dSopenharmony_ci 2069762338dSopenharmony_ciBENCHMARK_REGISTER_F(HdfUsbdBenchmarkTransferTest, SUB_USB_HostManager_HDI_Performance_1400) 2079762338dSopenharmony_ci ->Iterations(ITERATION_FREQUENCY) 2089762338dSopenharmony_ci ->Repetitions(REPETITION_FREQUENCY) 2099762338dSopenharmony_ci ->ReportAggregatesOnly(); 2109762338dSopenharmony_ci 2119762338dSopenharmony_ci/** 2129762338dSopenharmony_ci * @tc.name: SUB_USB_HostManager_HDI_Performance_1500 2139762338dSopenharmony_ci * @tc.desc: Benchmark test 2149762338dSopenharmony_ci * @tc.desc: Test functions to BulkTransferWrite(const UsbDev &dev, const UsbPipe &pipe, int32_t timeout, 2159762338dSopenharmony_ci * std::vector<uint8_t> &data); 2169762338dSopenharmony_ci * @tc.desc: Positive test: parameters correctly 2179762338dSopenharmony_ci * @tc.type: FUNC 2189762338dSopenharmony_ci */ 2199762338dSopenharmony_ciBENCHMARK_F(HdfUsbdBenchmarkTransferTest, SUB_USB_HostManager_HDI_Performance_1500) 2209762338dSopenharmony_ci(benchmark::State& st) 2219762338dSopenharmony_ci{ 2229762338dSopenharmony_ci ASSERT_TRUE(g_usbInterface != nullptr); 2239762338dSopenharmony_ci sptr<UsbSubscriberTest> subscriber = new UsbSubscriberTest(); 2249762338dSopenharmony_ci ASSERT_TRUE(subscriber != nullptr); 2259762338dSopenharmony_ci InitPara(subscriber); 2269762338dSopenharmony_ci struct UsbDev dev = dev_; 2279762338dSopenharmony_ci uint8_t interfaceId = INTERFACEID_OK; 2289762338dSopenharmony_ci uint8_t pointId = POINTID_BULK_OUT; 2299762338dSopenharmony_ci auto ret = g_usbInterface->ClaimInterface(dev, interfaceId, 1); 2309762338dSopenharmony_ci ASSERT_EQ(0, ret); 2319762338dSopenharmony_ci OHOS::HDI::Usb::V1_0::UsbPipe pipe = { interfaceId, pointId }; 2329762338dSopenharmony_ci std::vector<uint8_t> bufferData = {'b', 'u', 'l', 'k', 'w', 'r', 'i', 't', 'e', '0', '1'}; 2339762338dSopenharmony_ci for (auto _ : st) { 2349762338dSopenharmony_ci ret = g_usbInterface->BulkTransferWrite(dev, pipe, TRANSFER_TIME_OUT, bufferData); 2359762338dSopenharmony_ci } 2369762338dSopenharmony_ci ASSERT_EQ(0, ret); 2379762338dSopenharmony_ci ReleasePara(subscriber); 2389762338dSopenharmony_ci} 2399762338dSopenharmony_ci 2409762338dSopenharmony_ciBENCHMARK_REGISTER_F(HdfUsbdBenchmarkTransferTest, SUB_USB_HostManager_HDI_Performance_1500) 2419762338dSopenharmony_ci ->Iterations(ITERATION_FREQUENCY) 2429762338dSopenharmony_ci ->Repetitions(REPETITION_FREQUENCY) 2439762338dSopenharmony_ci ->ReportAggregatesOnly(); 2449762338dSopenharmony_ci 2459762338dSopenharmony_ci/** 2469762338dSopenharmony_ci * @tc.name: SUB_USB_HostManager_HDI_Performance_1600 2479762338dSopenharmony_ci * @tc.desc: Benchmark test 2489762338dSopenharmony_ci * @tc.desc: Test functions to InterruptTransferRead(const UsbDev &dev, const UsbPipe &pipe, int32_t timeout, 2499762338dSopenharmony_ci * std::vector<uint8_t> &data); 2509762338dSopenharmony_ci * @tc.desc: Positive test: parameters correctly 2519762338dSopenharmony_ci * @tc.type: FUNC 2529762338dSopenharmony_ci */ 2539762338dSopenharmony_ciBENCHMARK_F(HdfUsbdBenchmarkTransferTest, SUB_USB_HostManager_HDI_Performance_1600) 2549762338dSopenharmony_ci(benchmark::State& st) 2559762338dSopenharmony_ci{ 2569762338dSopenharmony_ci ASSERT_TRUE(g_usbInterface != nullptr); 2579762338dSopenharmony_ci sptr<UsbSubscriberTest> subscriber = new UsbSubscriberTest(); 2589762338dSopenharmony_ci ASSERT_TRUE(subscriber != nullptr); 2599762338dSopenharmony_ci InitPara(subscriber); 2609762338dSopenharmony_ci struct UsbDev dev = dev_; 2619762338dSopenharmony_ci uint8_t interfaceId = INTERFACEID_OK; 2629762338dSopenharmony_ci uint8_t pointId = POINTID_BULK_IN; 2639762338dSopenharmony_ci auto ret = g_usbInterface->ClaimInterface(dev, interfaceId, 1); 2649762338dSopenharmony_ci ASSERT_EQ(0, ret); 2659762338dSopenharmony_ci OHOS::HDI::Usb::V1_0::UsbPipe pipe = { interfaceId, pointId }; 2669762338dSopenharmony_ci std::vector<uint8_t> bufferData(MAX_BUFFER_LENGTH); 2679762338dSopenharmony_ci for (auto _ : st) { 2689762338dSopenharmony_ci ret = g_usbInterface->InterruptTransferRead(dev, pipe, TRANSFER_TIME_OUT, bufferData); 2699762338dSopenharmony_ci } 2709762338dSopenharmony_ci ASSERT_EQ(0, ret); 2719762338dSopenharmony_ci ReleasePara(subscriber); 2729762338dSopenharmony_ci} 2739762338dSopenharmony_ci 2749762338dSopenharmony_ciBENCHMARK_REGISTER_F(HdfUsbdBenchmarkTransferTest, SUB_USB_HostManager_HDI_Performance_1600) 2759762338dSopenharmony_ci ->Iterations(ITERATION_FREQUENCY) 2769762338dSopenharmony_ci ->Repetitions(REPETITION_FREQUENCY) 2779762338dSopenharmony_ci ->ReportAggregatesOnly(); 2789762338dSopenharmony_ci 2799762338dSopenharmony_ci/** 2809762338dSopenharmony_ci * @tc.name: SUB_USB_HostManager_HDI_Performance_1700 2819762338dSopenharmony_ci * @tc.desc: Benchmark test 2829762338dSopenharmony_ci * @tc.desc: Test functions to InterruptTransferWrite(const UsbDev &dev, const UsbPipe &pipe, int32_t timeout, 2839762338dSopenharmony_ci * std::vector<uint8_t> &data); 2849762338dSopenharmony_ci * @tc.desc: Positive test: parameters correctly 2859762338dSopenharmony_ci * @tc.type: FUNC 2869762338dSopenharmony_ci */ 2879762338dSopenharmony_ciBENCHMARK_F(HdfUsbdBenchmarkTransferTest, SUB_USB_HostManager_HDI_Performance_1700) 2889762338dSopenharmony_ci(benchmark::State& st) 2899762338dSopenharmony_ci{ 2909762338dSopenharmony_ci ASSERT_TRUE(g_usbInterface != nullptr); 2919762338dSopenharmony_ci sptr<UsbSubscriberTest> subscriber = new UsbSubscriberTest(); 2929762338dSopenharmony_ci ASSERT_TRUE(subscriber != nullptr); 2939762338dSopenharmony_ci InitPara(subscriber); 2949762338dSopenharmony_ci struct UsbDev dev = dev_; 2959762338dSopenharmony_ci uint8_t interfaceId = INTERFACEID_OK; 2969762338dSopenharmony_ci uint8_t pointId = POINTID_BULK_OUT; 2979762338dSopenharmony_ci auto ret = g_usbInterface->ClaimInterface(dev, interfaceId, 1); 2989762338dSopenharmony_ci ASSERT_EQ(0, ret); 2999762338dSopenharmony_ci OHOS::HDI::Usb::V1_0::UsbPipe pipe = { interfaceId, pointId }; 3009762338dSopenharmony_ci std::vector<uint8_t> bufferData = {'i', 'n', 't', 'w', 'r', 'i', 't', 'e', '0', '1'}; 3019762338dSopenharmony_ci for (auto _ : st) { 3029762338dSopenharmony_ci ret = g_usbInterface->InterruptTransferWrite(dev, pipe, TRANSFER_TIME_OUT, bufferData); 3039762338dSopenharmony_ci } 3049762338dSopenharmony_ci ASSERT_EQ(0, ret); 3059762338dSopenharmony_ci ReleasePara(subscriber); 3069762338dSopenharmony_ci} 3079762338dSopenharmony_ci 3089762338dSopenharmony_ciBENCHMARK_REGISTER_F(HdfUsbdBenchmarkTransferTest, SUB_USB_HostManager_HDI_Performance_1700) 3099762338dSopenharmony_ci ->Iterations(ITERATION_FREQUENCY) 3109762338dSopenharmony_ci ->Repetitions(REPETITION_FREQUENCY) 3119762338dSopenharmony_ci ->ReportAggregatesOnly(); 3129762338dSopenharmony_ci 3139762338dSopenharmony_ci/** 3149762338dSopenharmony_ci * @tc.name: SUB_USB_HostManager_HDI_Performance_1800 3159762338dSopenharmony_ci * @tc.desc: Benchmark test 3169762338dSopenharmony_ci * @tc.desc: Test functions to IsoTransferRead(const UsbDev &dev, const UsbPipe &pipe, int32_t timeout, 3179762338dSopenharmony_ci * std::vector<uint8_t> &data); 3189762338dSopenharmony_ci * @tc.desc: Positive test: parameters correctly 3199762338dSopenharmony_ci * @tc.type: FUNC 3209762338dSopenharmony_ci */ 3219762338dSopenharmony_ciBENCHMARK_F(HdfUsbdBenchmarkTransferTest, SUB_USB_HostManager_HDI_Performance_1800) 3229762338dSopenharmony_ci(benchmark::State& st) 3239762338dSopenharmony_ci{ 3249762338dSopenharmony_ci ASSERT_TRUE(g_usbInterface != nullptr); 3259762338dSopenharmony_ci sptr<UsbSubscriberTest> subscriber = new UsbSubscriberTest(); 3269762338dSopenharmony_ci ASSERT_TRUE(subscriber != nullptr); 3279762338dSopenharmony_ci InitPara(subscriber); 3289762338dSopenharmony_ci struct UsbDev dev = dev_; 3299762338dSopenharmony_ci uint8_t interfaceId = INTERFACEID_OK; 3309762338dSopenharmony_ci uint8_t pointId = POINTID_BULK_IN; 3319762338dSopenharmony_ci auto ret = g_usbInterface->ClaimInterface(dev, interfaceId, 1); 3329762338dSopenharmony_ci ASSERT_EQ(0, ret); 3339762338dSopenharmony_ci OHOS::HDI::Usb::V1_0::UsbPipe pipe = { interfaceId, pointId }; 3349762338dSopenharmony_ci std::vector<uint8_t> bufferData(MAX_BUFFER_LENGTH); 3359762338dSopenharmony_ci for (auto _ : st) { 3369762338dSopenharmony_ci ret = g_usbInterface->IsoTransferRead(dev, pipe, TRANSFER_TIME_OUT, bufferData); 3379762338dSopenharmony_ci } 3389762338dSopenharmony_ci ASSERT_EQ(0, ret); 3399762338dSopenharmony_ci ReleasePara(subscriber); 3409762338dSopenharmony_ci} 3419762338dSopenharmony_ci 3429762338dSopenharmony_ciBENCHMARK_REGISTER_F(HdfUsbdBenchmarkTransferTest, SUB_USB_HostManager_HDI_Performance_1800) 3439762338dSopenharmony_ci ->Iterations(ITERATION_FREQUENCY) 3449762338dSopenharmony_ci ->Repetitions(REPETITION_FREQUENCY) 3459762338dSopenharmony_ci ->ReportAggregatesOnly(); 3469762338dSopenharmony_ci 3479762338dSopenharmony_ci/** 3489762338dSopenharmony_ci * @tc.name: SUB_USB_HostManager_HDI_Performance_1900 3499762338dSopenharmony_ci * @tc.desc: Benchmark test 3509762338dSopenharmony_ci * @tc.desc: Test functions to IsoTransferWrite(const UsbDev &dev, const UsbPipe &pipe, int32_t timeout, 3519762338dSopenharmony_ci * std::vector<uint8_t> &data); 3529762338dSopenharmony_ci * @tc.desc: Positive test: parameters correctly 3539762338dSopenharmony_ci * @tc.type: FUNC 3549762338dSopenharmony_ci */ 3559762338dSopenharmony_ciBENCHMARK_F(HdfUsbdBenchmarkTransferTest, SUB_USB_HostManager_HDI_Performance_1900) 3569762338dSopenharmony_ci(benchmark::State& st) 3579762338dSopenharmony_ci{ 3589762338dSopenharmony_ci ASSERT_TRUE(g_usbInterface != nullptr); 3599762338dSopenharmony_ci sptr<UsbSubscriberTest> subscriber = new UsbSubscriberTest(); 3609762338dSopenharmony_ci ASSERT_TRUE(subscriber != nullptr); 3619762338dSopenharmony_ci InitPara(subscriber); 3629762338dSopenharmony_ci struct UsbDev dev = dev_; 3639762338dSopenharmony_ci uint8_t interfaceId = INTERFACEID_OK; 3649762338dSopenharmony_ci uint8_t pointId = POINTID_BULK_OUT; 3659762338dSopenharmony_ci auto ret = g_usbInterface->ClaimInterface(dev, interfaceId, 1); 3669762338dSopenharmony_ci ASSERT_EQ(0, ret); 3679762338dSopenharmony_ci OHOS::HDI::Usb::V1_0::UsbPipe pipe = { interfaceId, pointId }; 3689762338dSopenharmony_ci std::vector<uint8_t> bufferData = {'i', 's', 'o', 'w', 'r', 'i', 't', 'e', '0', '1'}; 3699762338dSopenharmony_ci for (auto _ : st) { 3709762338dSopenharmony_ci ret = g_usbInterface->IsoTransferWrite(dev, pipe, TRANSFER_TIME_OUT, bufferData); 3719762338dSopenharmony_ci } 3729762338dSopenharmony_ci ASSERT_EQ(0, ret); 3739762338dSopenharmony_ci ReleasePara(subscriber); 3749762338dSopenharmony_ci} 3759762338dSopenharmony_ci 3769762338dSopenharmony_ciBENCHMARK_REGISTER_F(HdfUsbdBenchmarkTransferTest, SUB_USB_HostManager_HDI_Performance_1900) 3779762338dSopenharmony_ci ->Iterations(ITERATION_FREQUENCY) 3789762338dSopenharmony_ci ->Repetitions(REPETITION_FREQUENCY) 3799762338dSopenharmony_ci ->ReportAggregatesOnly(); 3809762338dSopenharmony_ci 3819762338dSopenharmony_ci/** 3829762338dSopenharmony_ci * @tc.name: SUB_USB_HostManager_HDI_Performance_2200 3839762338dSopenharmony_ci * @tc.desc: Benchmark test 3849762338dSopenharmony_ci * @tc.desc: Test functions to int32_t BulkWrite(const UsbDev &dev, const UsbPipe &pipe, const sptr<Ashmem> &ashmem) 3859762338dSopenharmony_ci * @tc.desc: Positive test: parameters correctly 3869762338dSopenharmony_ci * @tc.type: FUNC 3879762338dSopenharmony_ci */ 3889762338dSopenharmony_ciBENCHMARK_F(HdfUsbdBenchmarkTransferTest, SUB_USB_HostManager_HDI_Performance_2200) 3899762338dSopenharmony_ci(benchmark::State& st) 3909762338dSopenharmony_ci{ 3919762338dSopenharmony_ci ASSERT_TRUE(g_usbInterface != nullptr); 3929762338dSopenharmony_ci sptr<UsbSubscriberTest> subscriber = new UsbSubscriberTest(); 3939762338dSopenharmony_ci ASSERT_TRUE(subscriber != nullptr); 3949762338dSopenharmony_ci InitPara(subscriber); 3959762338dSopenharmony_ci sptr<Ashmem> ashmem; 3969762338dSopenharmony_ci uint8_t rflg = 0; 3979762338dSopenharmony_ci int32_t asmSize = MAX_BUFFER_LENGTH; 3989762338dSopenharmony_ci struct UsbDev dev = dev_; 3999762338dSopenharmony_ci uint8_t interfaceId = INTERFACEID_OK; 4009762338dSopenharmony_ci uint8_t pointId = POINTID_BULK_IN; 4019762338dSopenharmony_ci auto ret = g_usbInterface->ClaimInterface(dev, interfaceId, 1); 4029762338dSopenharmony_ci ASSERT_EQ(0, ret); 4039762338dSopenharmony_ci OHOS::HDI::Usb::V1_0::UsbPipe pipe = { interfaceId, pointId }; 4049762338dSopenharmony_ci (void)InitAshmemOne(ashmem, asmSize, rflg); 4059762338dSopenharmony_ci for (auto _ : st) { 4069762338dSopenharmony_ci ret = g_usbInterface->BulkWrite(dev, pipe, ashmem); 4079762338dSopenharmony_ci } 4089762338dSopenharmony_ci ASSERT_EQ(ret, 0); 4099762338dSopenharmony_ci ReleasePara(subscriber); 4109762338dSopenharmony_ci} 4119762338dSopenharmony_ci 4129762338dSopenharmony_ciBENCHMARK_REGISTER_F(HdfUsbdBenchmarkTransferTest, SUB_USB_HostManager_HDI_Performance_2200) 4139762338dSopenharmony_ci ->Iterations(ITERATION_FREQUENCY) 4149762338dSopenharmony_ci ->Repetitions(REPETITION_FREQUENCY) 4159762338dSopenharmony_ci ->ReportAggregatesOnly(); 4169762338dSopenharmony_ci 4179762338dSopenharmony_ci/** 4189762338dSopenharmony_ci * @tc.name: SUB_USB_HostManager_HDI_Performance_2300 4199762338dSopenharmony_ci * @tc.desc: Benchmark test 4209762338dSopenharmony_ci * @tc.desc: Test functions to int32_t BulkRead(const UsbDev &dev, const UsbPipe &pipe, const sptr<Ashmem> &ashmem) 4219762338dSopenharmony_ci * @tc.desc: Positive test: parameters correctly 4229762338dSopenharmony_ci * @tc.type: FUNC 4239762338dSopenharmony_ci */ 4249762338dSopenharmony_ciBENCHMARK_F(HdfUsbdBenchmarkTransferTest, SUB_USB_HostManager_HDI_Performance_2300) 4259762338dSopenharmony_ci(benchmark::State& st) 4269762338dSopenharmony_ci{ 4279762338dSopenharmony_ci ASSERT_TRUE(g_usbInterface != nullptr); 4289762338dSopenharmony_ci sptr<UsbSubscriberTest> subscriber = new UsbSubscriberTest(); 4299762338dSopenharmony_ci ASSERT_TRUE(subscriber != nullptr); 4309762338dSopenharmony_ci InitPara(subscriber); 4319762338dSopenharmony_ci sptr<Ashmem> ashmem; 4329762338dSopenharmony_ci uint8_t rflg = 0; 4339762338dSopenharmony_ci int32_t asmSize = MAX_BUFFER_LENGTH; 4349762338dSopenharmony_ci struct UsbDev dev = dev_; 4359762338dSopenharmony_ci uint8_t interfaceId = INTERFACEID_OK; 4369762338dSopenharmony_ci uint8_t pointId = POINTID_BULK_IN; 4379762338dSopenharmony_ci auto ret = g_usbInterface->ClaimInterface(dev, interfaceId, 1); 4389762338dSopenharmony_ci ASSERT_EQ(0, ret); 4399762338dSopenharmony_ci OHOS::HDI::Usb::V1_0::UsbPipe pipe = { interfaceId, pointId }; 4409762338dSopenharmony_ci (void)InitAshmemOne(ashmem, asmSize, rflg); 4419762338dSopenharmony_ci for (auto _ : st) { 4429762338dSopenharmony_ci ret = g_usbInterface->BulkRead(dev, pipe, ashmem); 4439762338dSopenharmony_ci } 4449762338dSopenharmony_ci ASSERT_EQ(ret, 0); 4459762338dSopenharmony_ci ReleasePara(subscriber); 4469762338dSopenharmony_ci} 4479762338dSopenharmony_ci 4489762338dSopenharmony_ciBENCHMARK_REGISTER_F(HdfUsbdBenchmarkTransferTest, SUB_USB_HostManager_HDI_Performance_2300) 4499762338dSopenharmony_ci ->Iterations(ITERATION_FREQUENCY) 4509762338dSopenharmony_ci ->Repetitions(REPETITION_FREQUENCY) 4519762338dSopenharmony_ci ->ReportAggregatesOnly(); 4529762338dSopenharmony_ci 4539762338dSopenharmony_ci/** 4549762338dSopenharmony_ci * @tc.name: SUB_USB_HostManager_HDI_Performance_2400 4559762338dSopenharmony_ci * @tc.desc: Benchmark test 4569762338dSopenharmony_ci * @tc.desc: int32_t RegBulkCallback(const UsbDev &dev, const UsbPipe &pipe, const sptr<IUsbdBulkCallback> &cb) 4579762338dSopenharmony_ci * @tc.desc: Positive test: parameters correctly 4589762338dSopenharmony_ci * @tc.type: FUNC 4599762338dSopenharmony_ci */ 4609762338dSopenharmony_ciBENCHMARK_F(HdfUsbdBenchmarkTransferTest, SUB_USB_HostManager_HDI_Performance_2400) 4619762338dSopenharmony_ci(benchmark::State& st) 4629762338dSopenharmony_ci{ 4639762338dSopenharmony_ci ASSERT_TRUE(g_usbInterface != nullptr); 4649762338dSopenharmony_ci sptr<UsbSubscriberTest> subscriber = new UsbSubscriberTest(); 4659762338dSopenharmony_ci ASSERT_TRUE(subscriber != nullptr); 4669762338dSopenharmony_ci InitPara(subscriber); 4679762338dSopenharmony_ci struct UsbDev dev = dev_; 4689762338dSopenharmony_ci uint8_t interfaceId = INTERFACEID_OK; 4699762338dSopenharmony_ci uint8_t pointId = POINTID_BULK_OUT; 4709762338dSopenharmony_ci OHOS::HDI::Usb::V1_0::UsbPipe pipe = {interfaceId, pointId}; 4719762338dSopenharmony_ci sptr<UsbdBulkCallbackTest> usbdBulkCallback = new UsbdBulkCallbackTest(); 4729762338dSopenharmony_ci auto ret = -1; 4739762338dSopenharmony_ci for (auto _ : st) { 4749762338dSopenharmony_ci ret = g_usbInterface->RegBulkCallback(dev, pipe, usbdBulkCallback); 4759762338dSopenharmony_ci } 4769762338dSopenharmony_ci ASSERT_EQ(ret, 0); 4779762338dSopenharmony_ci ReleasePara(subscriber); 4789762338dSopenharmony_ci} 4799762338dSopenharmony_ci 4809762338dSopenharmony_ciBENCHMARK_REGISTER_F(HdfUsbdBenchmarkTransferTest, SUB_USB_HostManager_HDI_Performance_2400) 4819762338dSopenharmony_ci ->Iterations(ITERATION_FREQUENCY) 4829762338dSopenharmony_ci ->Repetitions(REPETITION_FREQUENCY) 4839762338dSopenharmony_ci ->ReportAggregatesOnly(); 4849762338dSopenharmony_ci 4859762338dSopenharmony_ci/** 4869762338dSopenharmony_ci * @tc.name: SUB_USB_HostManager_HDI_Performance_2500 4879762338dSopenharmony_ci * @tc.desc: Benchmark test 4889762338dSopenharmony_ci * @tc.desc: Test functions to int32_t UnRegBulkCallback(const UsbDev &dev, const UsbPipe &pipe) 4899762338dSopenharmony_ci * @tc.desc: Positive test: parameters correctly 4909762338dSopenharmony_ci * @tc.type: FUNC 4919762338dSopenharmony_ci */ 4929762338dSopenharmony_ciBENCHMARK_F(HdfUsbdBenchmarkTransferTest, SUB_USB_HostManager_HDI_Performance_2500) 4939762338dSopenharmony_ci(benchmark::State& st) 4949762338dSopenharmony_ci{ 4959762338dSopenharmony_ci ASSERT_TRUE(g_usbInterface != nullptr); 4969762338dSopenharmony_ci sptr<UsbSubscriberTest> subscriber = new UsbSubscriberTest(); 4979762338dSopenharmony_ci ASSERT_TRUE(subscriber != nullptr); 4989762338dSopenharmony_ci InitPara(subscriber); 4999762338dSopenharmony_ci struct UsbDev dev = dev_; 5009762338dSopenharmony_ci uint8_t interfaceId = INTERFACEID_OK; 5019762338dSopenharmony_ci uint8_t pointId = POINTID_BULK_OUT; 5029762338dSopenharmony_ci OHOS::HDI::Usb::V1_0::UsbPipe pipe = {interfaceId, pointId}; 5039762338dSopenharmony_ci sptr<UsbdBulkCallbackTest> usbdBulkCallback = new UsbdBulkCallbackTest(); 5049762338dSopenharmony_ci auto ret = g_usbInterface->RegBulkCallback(dev, pipe, usbdBulkCallback); 5059762338dSopenharmony_ci ASSERT_EQ(ret, 0); 5069762338dSopenharmony_ci for (auto _ : st) { 5079762338dSopenharmony_ci ret = g_usbInterface->UnRegBulkCallback(dev, pipe); 5089762338dSopenharmony_ci } 5099762338dSopenharmony_ci ASSERT_EQ(ret, 0); 5109762338dSopenharmony_ci ReleasePara(subscriber); 5119762338dSopenharmony_ci} 5129762338dSopenharmony_ci 5139762338dSopenharmony_ciBENCHMARK_REGISTER_F(HdfUsbdBenchmarkTransferTest, SUB_USB_HostManager_HDI_Performance_2500) 5149762338dSopenharmony_ci ->Iterations(ITERATION_FREQUENCY) 5159762338dSopenharmony_ci ->Repetitions(REPETITION_FREQUENCY) 5169762338dSopenharmony_ci ->ReportAggregatesOnly(); 5179762338dSopenharmony_ci 5189762338dSopenharmony_ci/** 5199762338dSopenharmony_ci * @tc.name: SUB_USB_HostManager_HDI_Performance_2600 5209762338dSopenharmony_ci * @tc.desc: Benchmark test 5219762338dSopenharmony_ci * @tc.desc: Test functions to int32_t BindUsbdSubscriber(const sptr<IUsbdSubscriber> &subscriber) 5229762338dSopenharmony_ci * @tc.desc: Positive test: parameters correctly 5239762338dSopenharmony_ci * @tc.type: FUNC 5249762338dSopenharmony_ci */ 5259762338dSopenharmony_ciBENCHMARK_F(HdfUsbdBenchmarkTransferTest, SUB_USB_HostManager_HDI_Performance_2600) 5269762338dSopenharmony_ci(benchmark::State& st) 5279762338dSopenharmony_ci{ 5289762338dSopenharmony_ci ASSERT_TRUE(g_usbInterface != nullptr); 5299762338dSopenharmony_ci sptr<UsbSubscriberTest> subscriber = new UsbSubscriberTest(); 5309762338dSopenharmony_ci ASSERT_TRUE(subscriber != nullptr); 5319762338dSopenharmony_ci InitPara(subscriber); 5329762338dSopenharmony_ci auto ret = -1; 5339762338dSopenharmony_ci for (auto _ : st) { 5349762338dSopenharmony_ci ret = g_usbInterface->BindUsbdSubscriber(subscriber); 5359762338dSopenharmony_ci } 5369762338dSopenharmony_ci ASSERT_EQ(0, ret); 5379762338dSopenharmony_ci ReleasePara(subscriber); 5389762338dSopenharmony_ci} 5399762338dSopenharmony_ci 5409762338dSopenharmony_ciBENCHMARK_REGISTER_F(HdfUsbdBenchmarkTransferTest, SUB_USB_HostManager_HDI_Performance_2600) 5419762338dSopenharmony_ci ->Iterations(ITERATION_FREQUENCY) 5429762338dSopenharmony_ci ->Repetitions(REPETITION_FREQUENCY) 5439762338dSopenharmony_ci ->ReportAggregatesOnly(); 5449762338dSopenharmony_ci 5459762338dSopenharmony_ci/** 5469762338dSopenharmony_ci * @tc.name: SUB_USB_HostManager_HDI_Performance_2700 5479762338dSopenharmony_ci * @tc.desc: Benchmark test 5489762338dSopenharmony_ci * @tc.desc: Test functions to int32_t UnbindUsbdSubscriber(const sptr<IUsbdSubscriber> &subscriber) 5499762338dSopenharmony_ci * @tc.desc: Positive test: parameters correctly 5509762338dSopenharmony_ci * @tc.type: FUNC 5519762338dSopenharmony_ci */ 5529762338dSopenharmony_ciBENCHMARK_F(HdfUsbdBenchmarkTransferTest, SUB_USB_HostManager_HDI_Performance_2700) 5539762338dSopenharmony_ci(benchmark::State& st) 5549762338dSopenharmony_ci{ 5559762338dSopenharmony_ci ASSERT_TRUE(g_usbInterface != nullptr); 5569762338dSopenharmony_ci sptr<UsbSubscriberTest> subscriber = new UsbSubscriberTest(); 5579762338dSopenharmony_ci ASSERT_TRUE(subscriber != nullptr); 5589762338dSopenharmony_ci auto ret = -1; 5599762338dSopenharmony_ci for (auto _ : st) { 5609762338dSopenharmony_ci ret = g_usbInterface->BindUsbdSubscriber(subscriber); 5619762338dSopenharmony_ci dev_ = {subscriber->busNum_, subscriber->devAddr_}; 5629762338dSopenharmony_ci ret = g_usbInterface->UnbindUsbdSubscriber(subscriber); 5639762338dSopenharmony_ci } 5649762338dSopenharmony_ci ASSERT_EQ(0, ret); 5659762338dSopenharmony_ci} 5669762338dSopenharmony_ci 5679762338dSopenharmony_ciBENCHMARK_REGISTER_F(HdfUsbdBenchmarkTransferTest, SUB_USB_HostManager_HDI_Performance_2700) 5689762338dSopenharmony_ci ->Iterations(ITERATION_FREQUENCY) 5699762338dSopenharmony_ci ->Repetitions(REPETITION_FREQUENCY) 5709762338dSopenharmony_ci ->ReportAggregatesOnly(); 5719762338dSopenharmony_ci 5729762338dSopenharmony_ci/** 5739762338dSopenharmony_ci * @tc.number : SUB_USB_HostManager_HDI_Performance_3200 5749762338dSopenharmony_ci * @tc.name : BulkTransferReadwithLengthBenchmarkTest 5759762338dSopenharmony_ci * @tc.desc : Test functions to BulkTransferReadwithLength benchmark test 5769762338dSopenharmony_ci * @tc.desc : BulkTransferReadwithLength ([in] struct UsbDev dev, [in] struct UsbPipe pipe, [in] int timeout, 5779762338dSopenharmony_ci * [in] int length, [out] unsigned char[] data) 5789762338dSopenharmony_ci * @tc.desc : Positive test: parameters correctly 5799762338dSopenharmony_ci * @tc.size : MediumTest 5809762338dSopenharmony_ci * @tc.type : Function 5819762338dSopenharmony_ci * @tc.level : Level 3 5829762338dSopenharmony_ci */ 5839762338dSopenharmony_ciBENCHMARK_F(HdfUsbdBenchmarkTransferTest, BulkTransferReadwithLengthBenchmarkTest) 5849762338dSopenharmony_ci(benchmark::State& st) 5859762338dSopenharmony_ci{ 5869762338dSopenharmony_ci ASSERT_TRUE(g_usbInterface != nullptr); 5879762338dSopenharmony_ci sptr<UsbSubscriberTest> subscriber = new UsbSubscriberTest(); 5889762338dSopenharmony_ci ASSERT_TRUE(subscriber != nullptr); 5899762338dSopenharmony_ci InitPara(subscriber); 5909762338dSopenharmony_ci struct UsbDev dev = dev_; 5919762338dSopenharmony_ci uint8_t interfaceId = INTERFACEID_OK; 5929762338dSopenharmony_ci uint8_t pointid = POINTID_BULK_IN; 5939762338dSopenharmony_ci auto ret = g_usbInterface->ClaimInterface(dev, interfaceId, 1); 5949762338dSopenharmony_ci ASSERT_EQ(0, ret); 5959762338dSopenharmony_ci OHOS::HDI::Usb::V1_0::UsbPipe pipe = {interfaceId, pointid}; 5969762338dSopenharmony_ci for (auto _ : st) { 5979762338dSopenharmony_ci std::vector<uint8_t> bufferData(MAX_BUFFER_LENGTH); 5989762338dSopenharmony_ci ret = g_usbInterface->BulkTransferReadwithLength(dev, pipe, TRANSFER_TIME_OUT, bufferData.size(), bufferData); 5999762338dSopenharmony_ci } 6009762338dSopenharmony_ci EXPECT_EQ(0, ret); 6019762338dSopenharmony_ci ReleasePara(subscriber); 6029762338dSopenharmony_ci} 6039762338dSopenharmony_ci 6049762338dSopenharmony_ciBENCHMARK_REGISTER_F(HdfUsbdBenchmarkTransferTest, BulkTransferReadwithLengthBenchmarkTest) 6059762338dSopenharmony_ci ->Iterations(ITERATION_FREQUENCY) 6069762338dSopenharmony_ci ->Repetitions(REPETITION_FREQUENCY) 6079762338dSopenharmony_ci ->ReportAggregatesOnly(); 6089762338dSopenharmony_ci 6099762338dSopenharmony_ci/** 6109762338dSopenharmony_ci * @tc.number : SUB_USB_HostManager_HDI_Performance_3300 6119762338dSopenharmony_ci * @tc.name : ControlTransferReadwithLengthBenchmarkTest 6129762338dSopenharmony_ci * @tc.desc : Test functions to ControlTransferReadwithLength benchmark test 6139762338dSopenharmony_ci * @tc.desc : ControlTransferReadwithLength ([in] struct UsbDev dev, [in] struct UsbPipe pipe, [in] int timeout, 6149762338dSopenharmony_ci * [in] int length, [out] unsigned char[] data) 6159762338dSopenharmony_ci * @tc.desc : Positive test: parameters correctly 6169762338dSopenharmony_ci * @tc.size : MediumTest 6179762338dSopenharmony_ci * @tc.type : Function 6189762338dSopenharmony_ci * @tc.level : Level 3 6199762338dSopenharmony_ci */ 6209762338dSopenharmony_ciBENCHMARK_F(HdfUsbdBenchmarkTransferTest, ControlTransferReadwithLengthBenchmarkTest) 6219762338dSopenharmony_ci(benchmark::State& st) 6229762338dSopenharmony_ci{ 6239762338dSopenharmony_ci ASSERT_TRUE(g_usbInterface != nullptr); 6249762338dSopenharmony_ci sptr<UsbSubscriberTest> subscriber = new UsbSubscriberTest(); 6259762338dSopenharmony_ci ASSERT_TRUE(subscriber != nullptr); 6269762338dSopenharmony_ci InitPara(subscriber); 6279762338dSopenharmony_ci struct UsbDev dev = dev_; 6289762338dSopenharmony_ci std::vector<uint8_t> bufferData(MAX_BUFFER_LENGTH); 6299762338dSopenharmony_ci struct UsbCtrlTransferParams ctrlparmas = { 6309762338dSopenharmony_ci USB_ENDPOINT_DIR_IN, USB_DDK_REQ_GET_CONFIGURATION, 0, 0, 0, TRANSFER_TIME_OUT}; 6319762338dSopenharmony_ci auto ret = -1; 6329762338dSopenharmony_ci for (auto _ : st) { 6339762338dSopenharmony_ci ret = g_usbInterface->ControlTransferReadwithLength(dev, ctrlparmas, bufferData); 6349762338dSopenharmony_ci } 6359762338dSopenharmony_ci EXPECT_EQ(0, ret); 6369762338dSopenharmony_ci ReleasePara(subscriber); 6379762338dSopenharmony_ci} 6389762338dSopenharmony_ci 6399762338dSopenharmony_ciBENCHMARK_REGISTER_F(HdfUsbdBenchmarkTransferTest, ControlTransferReadwithLengthBenchmarkTest) 6409762338dSopenharmony_ci ->Iterations(ITERATION_FREQUENCY) 6419762338dSopenharmony_ci ->Repetitions(REPETITION_FREQUENCY) 6429762338dSopenharmony_ci ->ReportAggregatesOnly(); 6439762338dSopenharmony_ci 6449762338dSopenharmony_ci} // namespace 6459762338dSopenharmony_ci 6469762338dSopenharmony_ciBENCHMARK_MAIN(); 647