From a264131f2fbba926fb5e213f5da00ef08fba8f48 Mon Sep 17 00:00:00 2001 From: Patrick Bellasi Date: Wed, 11 May 2016 09:53:40 +0100 Subject: [PATCH] ipynb: android: update recent fling to be more generic This patch adds these updates: 1. ANDROID_HOME setup 2. Simplified TestEnv configuration 3. Open apps support for Android N 4. Fling coords based on display resolution based Signed-off-by: Patrick Bellasi --- .../workloads/Android_Recents_Fling.ipynb | 246 ++++++++++-------- 1 file changed, 143 insertions(+), 103 deletions(-) diff --git a/ipynb/android/workloads/Android_Recents_Fling.ipynb b/ipynb/android/workloads/Android_Recents_Fling.ipynb index 652726a40..9781e566e 100644 --- a/ipynb/android/workloads/Android_Recents_Fling.ipynb +++ b/ipynb/android/workloads/Android_Recents_Fling.ipynb @@ -85,59 +85,53 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "In case more than one Android device are conencted to the host, you must specify the ID of the device you want to target in `my_target_conf`. Run `adb devices` on your host to get the ID." + "Devlib requires the ANDROID_HOME environment variable configured to point to your local installation of the Android SDK. If you have not this variable configured in the shell used to start the notebook server, you need to run the next cell to define where your Android SDK is installed." ] }, { "cell_type": "code", "execution_count": 3, "metadata": { - "collapsed": false + "collapsed": true }, "outputs": [], "source": [ - "# Setup a target configuration\n", - "my_target_conf = {\n", - " \n", - " # Target platform and board\n", - " \"platform\" : 'android',\n", - "\n", - " # Add target support\n", - " \"board\" : 'n5x',\n", - "\n", - " # Device ID\n", - " #\"device\" : \"00b1346f0878ccb1\",\n", - " \n", - " # Define devlib modules to load\n", - " \"modules\" : [\n", - " 'cpufreq' # enable CPUFreq support\n", - " ],\n", - "}" + "import os\n", + "os.environ['ANDROID_HOME'] = '/ext/android-sdk-linux/'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "In case more than one Android device are conencted to the host, you must specify the ID of the device you want to target in `my_target_conf`. Run `adb devices` on your host to get the ID." ] }, { "cell_type": "code", "execution_count": 4, "metadata": { - "collapsed": false, - "scrolled": false + "collapsed": false }, "outputs": [], "source": [ - "my_tests_conf = {\n", + "# Setup a target configuration\n", + "my_conf = {\n", + " \n", + " # Target platform and board\n", + " \"platform\" : 'android',\n", + "\n", + " # Device ID\n", + " # \"device\" : \"0123456789abcdef\",\n", "\n", " # Folder where all the results will be collected\n", " \"results_dir\" : \"Android_RecentsFling\",\n", - "\n", - " # Platform configurations to test\n", - " \"confs\" : [\n", - " {\n", - " \"tag\" : \"recentsfling\",\n", - " \"flags\" : \"ftrace\", # Enable FTrace events\n", - " \"sched_features\" : \"ENERGY_AWARE\", # enable EAS\n", - " },\n", - " ],\n", " \n", + " # Define devlib modules to load\n", + " \"modules\" : [\n", + " 'cpufreq' # enable CPUFreq support\n", + " ],\n", + "\n", " # FTrace events to collect for all the tests configuration which have\n", " # the \"ftrace\" flag enabled\n", " \"ftrace\" : {\n", @@ -149,7 +143,7 @@ " ],\n", " \"buffsize\" : 10 * 1024,\n", " },\n", - " \n", + "\n", " # Tools required by the experiments\n", " \"tools\" : [ 'trace-cmd' ],\n", "}" @@ -167,34 +161,33 @@ "name": "stderr", "output_type": "stream", "text": [ - "2016-04-25 17:12:19,000 INFO : Target - Using base path: /home/pippo/work/lisa\n", - "2016-04-25 17:12:19,001 INFO : Target - Loading custom (inline) target configuration\n", - "2016-04-25 17:12:19,001 INFO : Target - Loading custom (inline) test configuration\n", - "2016-04-25 17:12:19,001 INFO : Target - Devlib modules to load: ['bl', 'cpufreq']\n", - "2016-04-25 17:12:19,002 INFO : Target - Connecting Android target [DEFAULT]\n", - "2016-04-25 17:12:19,380 INFO : Target - Initializing target workdir:\n", - "2016-04-25 17:12:19,381 INFO : Target - /data/local/tmp/devlib-target\n", - "2016-04-25 17:12:21,581 INFO : Target - Topology:\n", - "2016-04-25 17:12:21,582 INFO : Target - [[0, 1, 2, 3], [4, 5]]\n", - "2016-04-25 17:12:22,699 INFO : FTrace - Enabled tracepoints:\n", - "2016-04-25 17:12:22,701 INFO : FTrace - sched_switch\n", - "2016-04-25 17:12:22,701 INFO : FTrace - sched_load_avg_cpu\n", - "2016-04-25 17:12:22,702 INFO : FTrace - cpu_frequency\n", - "2016-04-25 17:12:22,703 INFO : FTrace - cpu_capacity\n", - "2016-04-25 17:12:22,703 WARNING : TestEnv - Wipe previous contents of the results folder:\n", - "2016-04-25 17:12:22,704 WARNING : TestEnv - /home/pippo/work/lisa/results/Android_RecentsFling\n", - "2016-04-25 17:12:22,725 INFO : TestEnv - Set results folder to:\n", - "2016-04-25 17:12:22,725 INFO : TestEnv - /home/pippo/work/lisa/results/Android_RecentsFling\n", - "2016-04-25 17:12:22,726 INFO : TestEnv - Experiment results available also in:\n", - "2016-04-25 17:12:22,726 INFO : TestEnv - /home/pippo/work/lisa/results_latest\n" + "2016-04-27 10:03:27,438 INFO : Target - Using base path: /home/derkling/Code/lisa\n", + "2016-04-27 10:03:27,439 INFO : Target - Loading custom (inline) target configuration\n", + "2016-04-27 10:03:27,440 INFO : Target - Devlib modules to load: ['cpufreq']\n", + "2016-04-27 10:03:27,441 INFO : Target - Connecting Android target [DEFAULT]\n", + "2016-04-27 10:03:29,160 INFO : Target - Initializing target workdir:\n", + "2016-04-27 10:03:29,161 INFO : Target - /data/local/tmp/devlib-target\n", + "2016-04-27 10:03:32,592 INFO : Target - Topology:\n", + "2016-04-27 10:03:32,593 INFO : Target - [[0, 1], [2, 3]]\n", + "2016-04-27 10:03:33,947 WARNING : Event [sched_load_avg_cpu] not available for tracing\n", + "2016-04-27 10:03:33,949 WARNING : Event [cpu_capacity] not available for tracing\n", + "2016-04-27 10:03:33,950 INFO : FTrace - Enabled tracepoints:\n", + "2016-04-27 10:03:33,950 INFO : FTrace - sched_switch\n", + "2016-04-27 10:03:33,951 INFO : FTrace - sched_load_avg_cpu\n", + "2016-04-27 10:03:33,951 INFO : FTrace - cpu_frequency\n", + "2016-04-27 10:03:33,952 INFO : FTrace - cpu_capacity\n", + "2016-04-27 10:03:33,953 WARNING : TestEnv - Wipe previous contents of the results folder:\n", + "2016-04-27 10:03:33,953 WARNING : TestEnv - /home/derkling/Code/lisa/results/Android_RecentsFling\n", + "2016-04-27 10:03:33,963 INFO : TestEnv - Set results folder to:\n", + "2016-04-27 10:03:33,963 INFO : TestEnv - /home/derkling/Code/lisa/results/Android_RecentsFling\n", + "2016-04-27 10:03:33,964 INFO : TestEnv - Experiment results available also in:\n", + "2016-04-27 10:03:33,964 INFO : TestEnv - /home/derkling/Code/lisa/results_latest\n" ] } ], "source": [ "# Initialize a test environment using:\n", - "# the provided target configuration (my_target_conf)\n", - "# the provided test configuration (my_test_conf)\n", - "te = TestEnv(target_conf=my_target_conf, test_conf=my_tests_conf)\n", + "te = TestEnv(my_conf)\n", "target = te.target" ] }, @@ -284,7 +277,7 @@ "cell_type": "code", "execution_count": 8, "metadata": { - "collapsed": true + "collapsed": false }, "outputs": [], "source": [ @@ -296,21 +289,47 @@ " :type n: int\n", " \"\"\"\n", " # Get a list of third-party packages\n", - " packages = target.execute('pm list packages -3 | cut -d: -f 2')\n", - " packages = packages.split('\\r\\n')\n", - " # Remove empty string\n", - " packages.pop()\n", + " android_version = target.getprop('ro.build.version.release')\n", + " if android_version >= 'N':\n", + " packages = target.execute('cmd package list packages | cut -d: -f 2')\n", + " packages = packages.splitlines()\n", + " else:\n", + " packages = target.execute('pm list packages -3 | cut -d: -f 2')\n", + " packages = packages.splitlines()\n", + "\n", + " # As a safe fallback let's use a list of standard Android AOSP apps which are always available\n", + " if len(packages) < 8:\n", + " packages = [\n", + " 'com.android.messaging',\n", + " 'com.android.calendar',\n", + " 'com.android.settings',\n", + " 'com.android.calculator2',\n", + " 'com.android.email',\n", + " 'com.android.music',\n", + " 'com.android.deskclock',\n", + " 'com.android.contacts',\n", + " ]\n", " \n", " LAUNCH_CMD = 'monkey -p {} -c android.intent.category.LAUNCHER 1 '\n", " \n", " if n > len(packages):\n", " n = len(packages)\n", " \n", - " logging.info('Opening {} apps...'.format(n))\n", - " for app in packages[:n]:\n", - " logging.debug(' Launching {}'.format(app))\n", - " target.execute(LAUNCH_CMD.format(app))\n", - " " + " logging.info('Trying to open %d apps...', n)\n", + " started = 0\n", + " for app in packages:\n", + " logging.debug(' Launching %s', app)\n", + " try:\n", + " target.execute(LAUNCH_CMD.format(app))\n", + " started = started + 1\n", + " logging.info(' %2d starting %s...', started, app)\n", + " except Exception:\n", + " pass\n", + " if started >= n:\n", + " break\n", + " \n", + " # Close Recents\n", + " target.execute('input keyevent KEYCODE_HOME')\n" ] }, { @@ -329,14 +348,18 @@ " # Reset framestats collection\n", " target.execute('dumpsys gfxinfo --reset')\n", " \n", + " w, h = target.screen_resolution\n", + " x = w/2\n", + " yl = int(0.2*h)\n", + " yh = int(0.9*h)\n", + " \n", " logging.info('Start Swiping Recents')\n", " for i in range(5):\n", " # Simulate two fast UP and DOWN swipes\n", - " target.execute('input swipe 500 1700 500 500 100')\n", - " target.execute('input swipe 500 500 500 1700 100')\n", - " # Simulate two slow UP and DOWN swipes\n", - " target.execute('input swipe 500 1700 500 500 1000')\n", - " target.execute('input swipe 500 500 500 1700 1000')\n", + " target.execute('input swipe {} {} {} {} 50'.format(x, yl, x, yh))\n", + " sleep(0.3)\n", + " target.execute('input swipe {} {} {} {} 50'.format(x, yh, x, yl))\n", + " sleep(0.7)\n", " logging.info('Swiping Recents Completed')\n", " \n", " # Get frame stats\n", @@ -344,7 +367,7 @@ " adb_command(target.adb_name, 'shell dumpsys gfxinfo com.android.systemui > {}'.format(framestats_file))\n", " \n", " # Close Recents\n", - " target.execute('input keyevent KEYCODE_BACK')\n", + " target.execute('input keyevent KEYCODE_HOME')\n", "\n", " return framestats_file" ] @@ -379,15 +402,16 @@ " \n", " # Parse trace\n", " tr = Trace(te.platform, exp_dir,\n", - " events=my_tests_conf['ftrace']['events'])\n", + " events=my_conf['ftrace']['events'])\n", " ta = TraceAnalysis(tr, te.platform)\n", " \n", " # return all the experiment data\n", " return {\n", " 'dir' : exp_dir,\n", " 'framestats_file' : framestats_file,\n", - " 'trace' : trace_file,\n", + " 'trace_file' : trace_file,\n", " 'ftrace' : tr.ftrace,\n", + " 'trace' : tr,\n", " 'ta' : ta\n", " }" ] @@ -414,7 +438,7 @@ }, "outputs": [], "source": [ - "N_APPS = 10" + "N_APPS = 20" ] }, { @@ -428,7 +452,21 @@ "name": "stderr", "output_type": "stream", "text": [ - "2016-04-25 17:12:23,896 INFO : Opening 10 apps...\n" + "2016-04-27 10:04:15,735 INFO : Trying to open 20 apps...\n", + "2016-04-27 10:04:19,062 INFO : 1 starting com.android.documentsui...\n", + "2016-04-27 10:04:20,636 INFO : 2 starting com.android.quicksearchbox...\n", + "2016-04-27 10:04:22,291 INFO : 3 starting com.android.messaging...\n", + "2016-04-27 10:04:26,125 INFO : 4 starting com.android.contacts...\n", + "2016-04-27 10:04:30,385 INFO : 5 starting com.android.calendar...\n", + "2016-04-27 10:04:33,122 INFO : 6 starting com.htc.android.ssdtest...\n", + "2016-04-27 10:04:37,992 INFO : 7 starting com.android.dialer...\n", + "2016-04-27 10:04:38,592 INFO : 8 starting com.android.gallery3d...\n", + "2016-04-27 10:04:45,168 INFO : 9 starting com.android.settings...\n", + "2016-04-27 10:04:45,718 INFO : 10 starting com.android.calculator2...\n", + "2016-04-27 10:04:46,798 INFO : 11 starting com.android.email...\n", + "2016-04-27 10:04:47,373 INFO : 12 starting com.android.music...\n", + "2016-04-27 10:04:49,977 INFO : 13 starting com.android.deskclock...\n", + "2016-04-27 10:04:52,633 INFO : 14 starting com.android.development...\n" ] } ], @@ -451,27 +489,27 @@ "execution_count": 13, "metadata": { "collapsed": false, - "scrolled": true + "scrolled": false }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "2016-04-25 17:12:30,603 INFO : ------------------------\n", - "2016-04-25 17:12:30,604 INFO : Run workload using performance governor\n", - "2016-04-25 17:12:39,662 INFO : Start Swiping Recents\n", - "2016-04-25 17:13:03,456 INFO : Swiping Recents Completed\n", - "2016-04-25 17:13:10,416 INFO : Parsing FTrace format...\n", - "2016-04-25 17:13:20,811 INFO : Collected events spans a 31.152 [s] time interval\n", - "2016-04-25 17:13:20,812 INFO : Set plots time range to (0.000000, 31.152401)[s]\n", - "2016-04-25 17:13:21,974 INFO : ------------------------\n", - "2016-04-25 17:13:21,974 INFO : Run workload using interactive governor\n", - "2016-04-25 17:13:29,693 INFO : Start Swiping Recents\n", - "2016-04-25 17:13:56,598 INFO : Swiping Recents Completed\n", - "2016-04-25 17:14:05,800 INFO : Parsing FTrace format...\n", - "2016-04-25 17:14:13,393 INFO : Collected events spans a 34.177 [s] time interval\n", - "2016-04-25 17:14:13,394 INFO : Set plots time range to (0.000000, 34.177226)[s]\n" + "2016-04-27 10:05:16,261 INFO : ------------------------\n", + "2016-04-27 10:05:16,261 INFO : Run workload using performance governor\n", + "2016-04-27 10:05:23,910 INFO : Start Swiping Recents\n", + "2016-04-27 10:05:34,043 INFO : Swiping Recents Completed\n", + "2016-04-27 10:05:37,908 INFO : Parsing FTrace format...\n", + "2016-04-27 10:05:41,305 INFO : Collected events spans a 16.850 [s] time interval\n", + "2016-04-27 10:05:41,306 INFO : Set plots time range to (0.000000, 16.849682)[s]\n", + "2016-04-27 10:05:41,659 INFO : ------------------------\n", + "2016-04-27 10:05:41,660 INFO : Run workload using interactive governor\n", + "2016-04-27 10:05:49,387 INFO : Start Swiping Recents\n", + "2016-04-27 10:06:00,339 INFO : Swiping Recents Completed\n", + "2016-04-27 10:06:05,640 INFO : Parsing FTrace format...\n", + "2016-04-27 10:06:08,702 INFO : Collected events spans a 17.899 [s] time interval\n", + "2016-04-27 10:06:08,703 INFO : Set plots time range to (0.000000, 17.898734)[s]\n" ] } ], @@ -507,20 +545,22 @@ "output_type": "stream", "text": [ "Frame Statistics for PERFORMANCE governor\n", - "Stats since: 37304374100ns\n", - "Total frames rendered: 216625\n", - "Janky frames: 39887 (18.41%)\n", - "90th percentile: 22ms\n", - "95th percentile: 27ms\n", - "99th percentile: 48ms\n", + "Stats since: 31757612331ns\n", + "Total frames rendered: 1052\n", + "Janky frames: 124 (11.79%)\n", + "50th percentile: 9ms\n", + "90th percentile: 17ms\n", + "95th percentile: 23ms\n", + "99th percentile: 34ms\n", "\n", "Frame Statistics for INTERACTIVE governor\n", - "Stats since: 37304374100ns\n", - "Total frames rendered: 217740\n", - "Janky frames: 39945 (18.35%)\n", - "90th percentile: 22ms\n", - "95th percentile: 27ms\n", - "99th percentile: 48ms\n", + "Stats since: 31757612331ns\n", + "Total frames rendered: 1527\n", + "Janky frames: 230 (15.06%)\n", + "50th percentile: 10ms\n", + "90th percentile: 19ms\n", + "95th percentile: 23ms\n", + "99th percentile: 34ms\n", "\n" ] } @@ -550,7 +590,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", - "version": "2.7.6" + "version": "2.7.11+" }, "toc": { "toc_cell": false, -- GitLab