Merge "Add micro-benchmark for media metrics"

gugelfrei
Glenn Kasten 5 years ago committed by Android (Google) Code Review
commit ae42acb34d

@ -0,0 +1,6 @@
cc_test {
name: "mediametrics_benchmarks",
srcs: ["mediametrics_benchmarks.cpp"],
shared_libs: ["libbinder", "libmediametrics",],
static_libs: ["libgoogle-benchmark"],
}

@ -0,0 +1,4 @@
This benchmark may fail occasionally, probably due to the binder queue being full.
If that happens, just re-run it and it will usually work eventually.
adb shell /data/nativetest64/media\_metrics/media\_metrics

@ -0,0 +1,47 @@
/*
* Copyright (C) 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <media/MediaMetricsItem.h>
#include <benchmark/benchmark.h>
class MyItem : public android::mediametrics::BaseItem {
public:
static bool mySubmitBuffer() {
// Deliberately lame so that we're measuring just the cost to deliver things to the service.
return submitBuffer("", 0);
}
};
static void BM_SubmitBuffer(benchmark::State& state)
{
while (state.KeepRunning()) {
MyItem myItem;
bool ok = myItem.mySubmitBuffer();
if (ok == false) {
// submitBuffer() currently uses one-way binder IPC, which provides unreliable delivery
// with at-most-one guarantee.
// It is expected that the call may occasionally fail if the one-way queue is full.
// The Iterations magic number below was tuned to reduce, but not eliminate, failures.
state.SkipWithError("failed");
return;
}
benchmark::ClobberMemory();
}
}
BENCHMARK(BM_SubmitBuffer)->Iterations(4000); // Adjust magic number until test runs
BENCHMARK_MAIN();
Loading…
Cancel
Save