mirror of
https://gitee.com/openharmony/xts_hats
synced 2025-03-04 00:18:58 +00:00
add audio benchmark tests
Signed-off-by: wwx1010008 <wangqian214@huawei.com> Change-Id: I707aa430d161ea4a9e4565c91d4f0e1fe1aa5483
This commit is contained in:
parent
3dba2c26d4
commit
342b786d15
@ -340,4 +340,19 @@ BENCHMARK_F(AudioAdapterBenchmarkTest, SetExtraParams)(benchmark::State &state)
|
||||
|
||||
BENCHMARK_REGISTER_F(AudioAdapterBenchmarkTest, SetExtraParams)->
|
||||
Iterations(ITERATION_FREQUENCY)->Repetitions(REPETITION_FREQUENCY)->ReportAggregatesOnly();
|
||||
|
||||
BENCHMARK_F(AudioAdapterBenchmarkTest, GetExtraParams)(benchmark::State &state)
|
||||
{
|
||||
int32_t ret;
|
||||
enum AudioExtParamKey key = AUDIO_EXT_PARAM_KEY_NONE;
|
||||
char condition[AUDIO_ADAPTER_BUF_TEST];
|
||||
char value[AUDIO_ADAPTER_BUF_TEST];
|
||||
uint32_t valueLen = AUDIO_ADAPTER_BUF_TEST;
|
||||
for (auto _ : state) {
|
||||
ret = adapter_->GetExtraParams(adapter_, key, condition, value, valueLen);
|
||||
}
|
||||
ASSERT_TRUE(ret == HDF_SUCCESS || ret == HDF_ERR_NOT_SUPPORT);
|
||||
}
|
||||
BENCHMARK_REGISTER_F(AudioAdapterBenchmarkTest, GetExtraParams)->
|
||||
Iterations(ITERATION_FREQUENCY)->Repetitions(REPETITION_FREQUENCY)->ReportAggregatesOnly();
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ const int TEST_SAMPLE_RATE_MASK_48000 = 48000;
|
||||
const int TEST_CHANNEL_COUNT = 2;
|
||||
const int32_t ITERATION_FREQUENCY = 100;
|
||||
const int32_t REPETITION_FREQUENCY = 3;
|
||||
const int32_t MMAP_SUGGUEST_REQ_SIZE = 1920;
|
||||
|
||||
class AudioCaptureBenchmarkTest : public benchmark::Fixture {
|
||||
public:
|
||||
@ -579,5 +580,34 @@ BENCHMARK_F(AudioCaptureBenchmarkTest, GetFrameCount)(benchmark::State &state)
|
||||
|
||||
BENCHMARK_REGISTER_F(AudioCaptureBenchmarkTest, GetFrameCount)->
|
||||
Iterations(ITERATION_FREQUENCY)->Repetitions(REPETITION_FREQUENCY)->ReportAggregatesOnly();
|
||||
|
||||
BENCHMARK_F(AudioCaptureBenchmarkTest, CheckSceneCapability)(benchmark::State &state)
|
||||
{
|
||||
int32_t ret;
|
||||
bool supported = false;
|
||||
struct AudioSceneDescriptor scenes = {};
|
||||
scenes.scene.id = 0;
|
||||
scenes.desc.pins = PIN_IN_MIC;
|
||||
scenes.desc.desc = strdup("mic");
|
||||
for (auto _ : state) {
|
||||
ret = capture_->CheckSceneCapability(capture_, &scenes, &supported);
|
||||
}
|
||||
EXPECT_EQ(HDF_SUCCESS, ret);
|
||||
free(scenes.desc.desc);
|
||||
}
|
||||
BENCHMARK_REGISTER_F(AudioCaptureBenchmarkTest, CheckSceneCapability)->
|
||||
Iterations(ITERATION_FREQUENCY)->Repetitions(REPETITION_FREQUENCY)->ReportAggregatesOnly();
|
||||
|
||||
BENCHMARK_F(AudioCaptureBenchmarkTest, ReqMmapBuffer)(benchmark::State &state)
|
||||
{
|
||||
int32_t ret;
|
||||
struct AudioMmapBufferDescriptor desc = {0};
|
||||
for (auto _ : state) {
|
||||
ret = capture_->ReqMmapBuffer(capture_, MMAP_SUGGUEST_REQ_SIZE, &desc);
|
||||
}
|
||||
ASSERT_TRUE(ret == HDF_SUCCESS || ret == HDF_ERR_NOT_SUPPORT ||ret == HDF_ERR_INVALID_PARAM);
|
||||
}
|
||||
BENCHMARK_REGISTER_F(AudioCaptureBenchmarkTest, ReqMmapBuffer)->
|
||||
Iterations(ITERATION_FREQUENCY)->Repetitions(REPETITION_FREQUENCY)->ReportAggregatesOnly();
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,7 @@ const int32_t MAX_AUDIO_ADAPTER_DESC = 5;
|
||||
const uint64_t DEFAULT_BUFFER_SIZE = 16384;
|
||||
const int32_t ITERATION_FREQUENCY = 100;
|
||||
const int32_t REPETITION_FREQUENCY = 3;
|
||||
const int32_t MMAP_SUGGEST_BUFFER_SIZE = 1920;
|
||||
|
||||
class AudioRenderBenchmarkTest : public benchmark::Fixture {
|
||||
public:
|
||||
@ -581,6 +582,20 @@ BENCHMARK_F(AudioRenderBenchmarkTest, SetChannelMode)(benchmark::State &state)
|
||||
BENCHMARK_REGISTER_F(AudioRenderBenchmarkTest, SetChannelMode)->
|
||||
Iterations(ITERATION_FREQUENCY)->Repetitions(REPETITION_FREQUENCY)->ReportAggregatesOnly();
|
||||
|
||||
BENCHMARK_F(AudioRenderBenchmarkTest, GetChannelMode)(benchmark::State &state)
|
||||
{
|
||||
int32_t ret;
|
||||
AudioChannelMode mode = AUDIO_CHANNEL_NORMAL;
|
||||
|
||||
for (auto _ : state) {
|
||||
ret = render_->GetChannelMode(render_, &mode);
|
||||
}
|
||||
ASSERT_TRUE(ret == HDF_SUCCESS || ret == HDF_ERR_NOT_SUPPORT);
|
||||
}
|
||||
|
||||
BENCHMARK_REGISTER_F(AudioRenderBenchmarkTest, GetChannelMode)->
|
||||
Iterations(ITERATION_FREQUENCY)->Repetitions(REPETITION_FREQUENCY)->ReportAggregatesOnly();
|
||||
|
||||
BENCHMARK_F(AudioRenderBenchmarkTest, SetRenderSpeed)(benchmark::State &state)
|
||||
{
|
||||
int32_t ret;
|
||||
@ -594,4 +609,47 @@ BENCHMARK_F(AudioRenderBenchmarkTest, SetRenderSpeed)(benchmark::State &state)
|
||||
|
||||
BENCHMARK_REGISTER_F(AudioRenderBenchmarkTest, SetRenderSpeed)->
|
||||
Iterations(ITERATION_FREQUENCY)->Repetitions(REPETITION_FREQUENCY)->ReportAggregatesOnly();
|
||||
}
|
||||
|
||||
BENCHMARK_F(AudioRenderBenchmarkTest, GetRenderSpeed)(benchmark::State &state)
|
||||
{
|
||||
int32_t ret;
|
||||
float speed = 0;
|
||||
|
||||
for (auto _ : state) {
|
||||
ret = render_->GetRenderSpeed(render_, &speed);
|
||||
}
|
||||
EXPECT_EQ(HDF_ERR_NOT_SUPPORT, ret);
|
||||
}
|
||||
BENCHMARK_REGISTER_F(AudioRenderBenchmarkTest, GetRenderSpeed)->
|
||||
Iterations(ITERATION_FREQUENCY)->Repetitions(REPETITION_FREQUENCY)->ReportAggregatesOnly();
|
||||
|
||||
BENCHMARK_F(AudioRenderBenchmarkTest, ReqMmapBuffer)(benchmark::State &state)
|
||||
{
|
||||
int32_t ret;
|
||||
int32_t reqSize = MMAP_SUGGEST_BUFFER_SIZE;
|
||||
struct AudioMmapBufferDescriptor desc;
|
||||
for (auto _ : state) {
|
||||
ret = render_->ReqMmapBuffer(render_, reqSize, &desc);
|
||||
}
|
||||
ASSERT_TRUE(ret == HDF_SUCCESS || ret == HDF_ERR_INVALID_PARAM);
|
||||
}
|
||||
BENCHMARK_REGISTER_F(AudioRenderBenchmarkTest, ReqMmapBuffer)->
|
||||
Iterations(ITERATION_FREQUENCY)->Repetitions(REPETITION_FREQUENCY)->ReportAggregatesOnly();
|
||||
|
||||
BENCHMARK_F(AudioRenderBenchmarkTest, CheckSceneCapability)(benchmark::State &state)
|
||||
{
|
||||
int32_t ret = -1;
|
||||
bool supported = false;
|
||||
struct AudioSceneDescriptor scenes = {};
|
||||
scenes.scene.id = 0;
|
||||
scenes.desc.pins = PIN_OUT_SPEAKER;
|
||||
scenes.desc.desc = strdup("mic");
|
||||
for (auto _ : state) {
|
||||
ret = render_->CheckSceneCapability(render_, &scenes, &supported);
|
||||
}
|
||||
EXPECT_EQ(HDF_SUCCESS, ret);
|
||||
free(scenes.desc.desc);
|
||||
}
|
||||
BENCHMARK_REGISTER_F(AudioRenderBenchmarkTest, CheckSceneCapability)->
|
||||
Iterations(ITERATION_FREQUENCY)->Repetitions(REPETITION_FREQUENCY)->ReportAggregatesOnly();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user