{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import trappy\n", "from trappy import ftrace\n", "from trappy.ftrace import GenericFTrace\n", "import numpy as np\n", "import pandas" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": true }, "outputs": [], "source": [ "lines = [\n", "\" adbd-5709 [007] 2943.184105: sched_contrib_scale_f: cpu=7 cpu_scale_factor=1\\n\"\n", "\" adbd-5709 [007] 2943.184105: sched_load_avg_cpu: cpu=7 util_avg=825\\n\"\n", "\" ->transport-5713 [006] 2943.184106: sched_load_avg_cpu: cpu=6 util_avg=292\\n\"\n", "\" ->transport-5713 [006] 2943.184107: sched_contrib_scale_f: cpu=6 cpu_scale_factor=2\\n\"\n", "\" adbd-5709 [007] 2943.184108: sched_load_avg_cpu: cpu=7 util_avg=850\\n\"\n", "\" adbd-5709 [007] 2943.184109: sched_contrib_scale_f: cpu=7 cpu_scale_factor=3\\n\"\n", "\" adbd-5709 [007] 2943.184110: sched_load_avg_cpu: cpu=6 util_avg=315\\n\"\n", "]" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": true }, "outputs": [], "source": [ "with open('/tmp/trappy_mergedf_example.txt', 'w') as fh:\n", " for line in lines:\n", " fh.write(line)" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " adbd-5709 [007] 2943.184105: sched_contrib_scale_f: cpu=7 cpu_scale_factor=1\r\n", " adbd-5709 [007] 2943.184105: sched_load_avg_cpu: cpu=7 util_avg=825\r\n", " ->transport-5713 [006] 2943.184106: sched_load_avg_cpu: cpu=6 util_avg=292\r\n", " ->transport-5713 [006] 2943.184107: sched_contrib_scale_f: cpu=6 cpu_scale_factor=2\r\n", " adbd-5709 [007] 2943.184108: sched_load_avg_cpu: cpu=7 util_avg=850\r\n", " adbd-5709 [007] 2943.184109: sched_contrib_scale_f: cpu=7 cpu_scale_factor=3\r\n", " adbd-5709 [007] 2943.184110: sched_load_avg_cpu: cpu=6 util_avg=315\r\n" ] } ], "source": [ "!cat /tmp/trappy_mergedf_example.txt" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": true }, "outputs": [], "source": [ "trace = ftrace.FTrace('/tmp/trappy_mergedf_example.txt', events=['sched_contrib_scale_f', 'sched_load_avg_cpu'], normalize_time=False)" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
cpuutil_avg__line
Time
2943.18410578251
2943.18410662922
2943.18410878504
2943.18411063156
\n", "
" ], "text/plain": [ " cpu util_avg __line\n", "Time \n", "2943.184105 7 825 1\n", "2943.184106 6 292 2\n", "2943.184108 7 850 4\n", "2943.184110 6 315 6" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df1 = trace.sched_load_avg_cpu.data_frame[['cpu', 'util_avg', '__line']]\n", "df1" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
cpucpu_scale_factor__line
Time
2943.184105710
2943.184107623
2943.184109735
\n", "
" ], "text/plain": [ " cpu cpu_scale_factor __line\n", "Time \n", "2943.184105 7 1 0\n", "2943.184107 6 2 3\n", "2943.184109 7 3 5" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df2 = trace.sched_contrib_scale_f.data_frame[['cpu', 'cpu_scale_factor', '__line']]\n", "df2" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "collapsed": false, "scrolled": true }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/home/joelaf/repo/lisa-aosp/external/trappy/trappy/utils.py:154: FutureWarning: sort(columns=....) is deprecated, use sort_values(by=.....)\n", " df = pd.concat([pr_df, sec_df], keys=['primary', 'secondary']).sort(columns='__line')\n" ] }, { "data": { "text/html": [ "
\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
__linecpucpu_scale_factorutil_avg
Time
2943.184105171.0825.0
2943.18410626NaN292.0
2943.184108471.0850.0
2943.184110662.0315.0
\n", "
" ], "text/plain": [ " __line cpu cpu_scale_factor util_avg\n", "Time \n", "2943.184105 1 7 1.0 825.0\n", "2943.184106 2 6 NaN 292.0\n", "2943.184108 4 7 1.0 850.0\n", "2943.184110 6 6 2.0 315.0" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "trappy.utils.merge_dfs(df1, df2, 'cpu')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "metadata": { "gist": { "data": { "description": "TRAPpy_MergeDF_API_Example", "public": false }, "id": "" }, "hide_input": false, "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.13" }, "toc": { "colors": { "hover_highlight": "#DAA520", "running_highlight": "#FF0000", "selected_highlight": "#FFD700" }, "moveMenuLeft": true, "nav_menu": { "height": "12px", "width": "252px" }, "navigate_menu": true, "number_sections": true, "sideBar": true, "threshold": 4, "toc_cell": false, "toc_section_display": "block", "toc_window_display": false } }, "nbformat": 4, "nbformat_minor": 1 }