Benchmark app analyses the time taken by MediaCodec, MediaExtractor and MediaMuxer for given set of inputs. It is used to benchmark these modules on android devices.
Benchmark results are emitted to logcat.
Benchmark results are published as a CSV report.
This page describes steps to run the NDK and SDK layer test.
@@ -10,35 +10,49 @@ Run the following steps to build the test suite:
mmm frameworks/av/media/tests/benchmark/
```
# NDK
# Resources
The resource file for the tests is taken from [here](https://storage.googleapis.com/android_media/frameworks/av/media/tests/benchmark/MediaBenchmark.zip)
Download the MediaBenchmark.zip file, unzip and push it to /data/local/tmp/ on the device.
The resource files are assumed to be at /data/local/tmp/MediaBenchmark/res/. You can use a different location, but you have to modify the rest of the instructions to replace /data/local/tmp/MediaBenchmark/res/ with wherever you chose to put the files.
# NDK CLI Tests
Note: [Benchmark Application](#BenchmarkApplication) now supports profiling both SDK and NDK APIs and that is the preferred way to benchmark codecs
To run the test suite for measuring performance of the native layer, follow the following steps:
The binaries will be created in the following path : $OUT/data/nativetest64/
The 64-bit binaries will be created in the following path : ${OUT}/data/nativetest64/
To run the binary, follow the commands mentioned below under each module.
## Extractor
The test extracts elementary stream and benchmarks the extractors available in NDK.
The resource files are assumed to be at /data/local/tmp/MediaBenchmark/res/. You can use a different location, but you have to modify the rest of the instructions to replace /data/local/tmp/MediaBenchmark/res/ with wherever you chose to put the files.
The path to these files on the device is required to be given for the test.
To get the resource files for the test follow instructions given in [Resources](#Resources)
For running all the tests, run the following command
```
adb shell am instrument -w -r -e package com.android.media.benchmark.tests com.android.media.benchmark/androidx.test.runner.AndroidJUnitRunner
```
## Extractor
The test extracts elementary stream and benchmarks the extractors available in SDK.
The test extracts elementary stream and benchmarks the extractors available in SDK and NDK.
```
adb shell am instrument -w -r -e class 'com.android.media.benchmark.tests.ExtractorTest' com.android.media.benchmark/androidx.test.runner.AndroidJUnitRunner
```
## Decoder
The test decodes input stream and benchmarks the decoders available in SDK.
The test decodes input stream and benchmarks the decoders available in SDK and NDK.
```
adb shell am instrument -w -r -e class 'com.android.media.benchmark.tests.DecoderTest' com.android.media.benchmark/androidx.test.runner.AndroidJUnitRunner
```
## Muxer
The test muxes elementary stream and benchmarks different writers available in SDK.
The test muxes elementary stream and benchmarks different writers available in SDK and NDK.
```
adb shell am instrument -w -r -e class 'com.android.media.benchmark.tests.MuxerTest' com.android.media.benchmark/androidx.test.runner.AndroidJUnitRunner
```
## Encoder
The test encodes input stream and benchmarks the encoders available in SDK.
The test encodes input stream and benchmarks the encoders available in SDK and NDK.
```
adb shell am instrument -w -r -e class 'com.android.media.benchmark.tests.EncoderTest' com.android.media.benchmark/androidx.test.runner.AndroidJUnitRunner
```
@@ -124,24 +161,27 @@ adb shell am instrument -w -r -e class 'com.android.media.benchmark.tests.Encode
To run the test suite for measuring performance of the codec2 layer, follow the following steps:
The 32-bit binaries will be created in the following path : ${OUT}/data/nativetest/
The 64-bit binaries will be created in the following path : ${OUT}/data/nativetest64/
To test 64-bit binary push binaries from nativetest64.
1.**currentTime** : The time recorded at the creation of the stats. This may be used to estimate time between consecutive test clips.
2.**fileName**: The file being used as an input for the benchmark test.
3.**operation**: The current operation on the input test vector i.e. Extract/Mux/Encode/Decode.
4.**NDK/SDK**: The target APIs i.e. AMedia vs Media calls for the operation being performed.
5.**sync/async**: This is specific to MediaCodec objects (i.e. Encoder and Decoder). It specifies the mode in which MediaCodec APIs are working. For async mode, callbacks are set. For sync mode, we have to poll the dequeueBuffer APIs to queue and dequeue input output buffers respectively.
6.**setupTime**: The time taken to set up the MediaExtractor/Muxer/Codec instance.
* MediaCodec: includes setting async/sync mode, configuring with a format and codec.start
* MediaExtractor: includes AMediaExtractor_new and setDataSource.
* MediaMuxer: includes creating the object, adding track, and starting the muxer.
7.**destroyTime**: The time taken to stop and close MediaExtractor/Muxer/Codec instance.
8.**minimumTime**: The minimum time taken to extract/mux/encode/decode a frame.
9.**maximumTime**: The maximum time taken to extract/mux/encode/decode a frame.
10.**averageTime**: Average time taken to extract/mux/encode/decode per frame.
* MediaCodec: computed as the total time taken to encode/decode all frames divided by the number of frames encoded/decoded.
* MediaExtractor: computed as the total time taken to extract all frames divided by the number of frames extracted.
* MediaMuxer: computed as the total time taken to mux all frames divided by the number of frames muxed.
11.**timeToProcess1SecContent**: The time required to process one second worth input data.
12.**totalBytesProcessedPerSec**: The number of bytes extracted/muxed/decoded/encoded per second.
13.**timeToFirstFrame**: The time taken to receive the first output frame.
14.**totalSizeInBytes**: The total output size of the operation (in bytes).
15.**totalTime**: The time taken to perform the complete operation (i.e. Extract/Mux/Decode/Encode) for respective test vector.
## Muxer
1.**componentName**: The format of the output Media file. Following muxers are currently supported:
* Ogg, Webm, 3gpp, and mp4.
## Decoder
1.**componentName**: Includes all supported codecs on the device. Aliased components are skipped.