1 /* 2 * Copyright (C) 2018 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.nn.benchmark.app; 18 19 import android.test.suitebuilder.annotation.LargeTest; 20 import android.test.suitebuilder.annotation.MediumTest; 21 22 import com.android.nn.benchmark.core.TestModels; 23 24 import org.junit.Test; 25 26 /** 27 * NNAPI benchmark test. 28 * To run the test, please use command 29 * 30 * adb shell am instrument -w 31 * com.android.nn.benchmark.app/androidx.test.runner.AndroidJUnitRunner 32 * 33 * To run only one model, please run: 34 * adb shell am instrument 35 * -e class "com.android.nn.benchmark.app.NNTest#testNNAPI[MODEL_NAME]" 36 * -w com.android.nn.benchmark.app/androidx.test.runner.AndroidJUnitRunner 37 * 38 */ 39 public class NNTest extends BenchmarkTestBase { 40 NNTest(TestModels.TestModelEntry model)41 public NNTest(TestModels.TestModelEntry model) { 42 super(model); 43 } 44 45 @Test 46 @MediumTest testNNAPI()47 public void testNNAPI() { 48 TestAction ta = new TestAction(mModel, WARMUP_SHORT_SECONDS, RUNTIME_SHORT_SECONDS); 49 runTest(ta, mModel.getTestName()); 50 } 51 52 @Test 53 @LargeTest testNNAPI10Seconds()54 public void testNNAPI10Seconds() { 55 TestAction ta = new TestAction(mModel, WARMUP_REPEATABLE_SECONDS, 56 RUNTIME_REPEATABLE_SECONDS); 57 runTest(ta, mModel.getTestName()); 58 } 59 60 @Test 61 @LargeTest testNNAPIAllData()62 public void testNNAPIAllData() { 63 setCompleteInputSet(true); 64 TestAction ta = new TestAction(mModel, WARMUP_REPEATABLE_SECONDS, 65 COMPLETE_SET_TIMEOUT_SECOND); 66 runTest(ta, mModel.getTestName()); 67 } 68 } 69