{ "metadata": { "kernelspec": { "display_name": "Python 2", "language": "python", "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.9" }, "name": "" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Setup" ] }, { "cell_type": "code", "collapsed": false, "input": [ "from trappy.stats.Topology import Topology\n", "from bart.sched.SchedMultiAssert import SchedMultiAssert\n", "from bart.sched.SchedAssert import SchedAssert\n", "import trappy\n", "import os\n", "import operator\n", "import json\n", "\n", "#Define a CPU Topology (for multi-cluster systems)\n", "BIG = [1, 2]\n", "LITTLE = [0, 3, 4, 5]\n", "CLUSTERS = [BIG, LITTLE]\n", "topology = Topology(clusters=CLUSTERS)\n", "\n", "BASE_PATH = \"/Users/kapileshwarsingh/AnalysisRawData/LPC/sched_deadline/\"\n", "\n", "THRESHOLD = 10.0\n", "def between_threshold(a, b):\n", " return abs(((a - b) * 100.0) / b) < THRESHOLD" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 3 }, { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Periodic Yield" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The thread periodic_yeild is woken up at 30ms intervals where it calls sched_yield and relinquishes its time-slice.\n", "The expectation is that the task will have a duty cycle < 1% and a period of 30ms.\n", "\n", "There are two threads, and the rank=1 conveys that the condition is true for one of the threads with the name \"periodic_yeild\"\n" ] }, { "cell_type": "code", "collapsed": false, "input": [ "TRACE_FILE = os.path.join(BASE_PATH, \"yield\")\n", "ftrace = trappy.FTrace(TRACE_FILE, \"cpuhog\")\n", "\n", "# Assert Period\n", "s = SchedMultiAssert(ftrace, topology, execnames=\"periodic_yield\")\n", "if s.assertPeriod(30, between_threshold, rank=1):\n", " print \"PASS: Period\"\n", " print json.dumps(s.getPeriod(), indent=3)\n", "\n", "print \"\"\n", " \n", "# Assert DutyCycle \n", "if s.assertDutyCycle(1, operator.lt, window=(0,4), rank=2):\n", " print \"PASS: DutyCycle\"\n", " print json.dumps(s.getDutyCycle(window=(0,4)), indent=3)" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "PASS: Period\n", "{\n", " \"1844\": {\n", " \"period\": 1.0085000000401578, \n", " \"task_name\": \"periodic_yield\"\n", " }, \n", " \"1845\": {\n", " \"period\": 29.822017857142669, \n", " \"task_name\": \"periodic_yield\"\n", " }\n", "}\n", "\n", "PASS: DutyCycle\n", "{\n", " \"1844\": {\n", " \"task_name\": \"periodic_yield\", \n", " \"dutycycle\": 0.074749999998857675\n", " }, \n", " \"1845\": {\n", " \"task_name\": \"periodic_yield\", \n", " \"dutycycle\": 0.03862499999343072\n", " }\n", "}\n" ] } ], "prompt_number": 10 }, { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "CPU Hog" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The reservation of a CPU hogging task is set to 10ms for every 100ms. The assertion ensures a duty cycle of 10%" ] }, { "cell_type": "code", "collapsed": false, "input": [ "TRACE_FILE = os.path.join(BASE_PATH, \"cpuhog\")\n", "ftrace = trappy.FTrace(TRACE_FILE, \"cpuhog\")\n", "s = SchedMultiAssert(ftrace, topology, execnames=\"cpuhog\")\n", "s.plot().view()\n", "\n", "# Assert DutyCycle\n", "if s.assertDutyCycle(10, between_threshold, window=(0, 5), rank=1):\n", " print \"PASS: DutyCycle\"\n", " print json.dumps(s.getDutyCycle(window=(0, 5)), indent=3)" ], "language": "python", "metadata": {}, "outputs": [ { "html": [ "\n", "