{ "cells": [ { "cell_type": "code", "execution_count": 35, "metadata": {}, "outputs": [], "source": [ "import pandas as pd " ] }, { "cell_type": "code", "execution_count": 45, "metadata": {}, "outputs": [], "source": [ "def get_function_name(function_name):\n", " return function_name[10:].rsplit(\".c\")[0]" ] }, { "cell_type": "code", "execution_count": 54, "metadata": { "scrolled": true }, "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", " \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", " \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", "
elapsed_timeexecutionsfunction_nameused_virtual_mem
00.0004561cgrid2877.4
10.1802641Py_kgeneration2877.9
20.001184512gasdev2882.6
30.000081700cov_value2877.9
40.0000151clean_real2877.9
50.0775141covariance2877.9
60.0791661fftma22877.9
70.1001231generate2877.4
80.0000983length2877.4
90.0000341Py_getvalues0.0
100.000037702ran22882.6
110.0001933fourt2877.9
120.0000331build_real2877.9
130.0000341prebuild_gwn2877.9
140.0000103maxfactor2877.4
\n", "
" ], "text/plain": [ " elapsed_time executions function_name used_virtual_mem\n", "0 0.000456 1 cgrid 2877.4\n", "1 0.180264 1 Py_kgeneration 2877.9\n", "2 0.001184 512 gasdev 2882.6\n", "3 0.000081 700 cov_value 2877.9\n", "4 0.000015 1 clean_real 2877.9\n", "5 0.077514 1 covariance 2877.9\n", "6 0.079166 1 fftma2 2877.9\n", "7 0.100123 1 generate 2877.4\n", "8 0.000098 3 length 2877.4\n", "9 0.000034 1 Py_getvalues 0.0\n", "10 0.000037 702 ran2 2882.6\n", "11 0.000193 3 fourt 2877.9\n", "12 0.000033 1 build_real 2877.9\n", "13 0.000034 1 prebuild_gwn 2877.9\n", "14 0.000010 3 maxfactor 2877.4" ] }, "execution_count": 54, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data = {}\n", "with open(\"log_8.txt\") as log_file:\n", " lines = log_file.readlines()\n", " \n", " for line in lines:\n", " if \"MEM\" in line:\n", " split_line = line.split()\n", " idx_used_mem = split_line.index(\"USED\") + 4\n", " function_name, used_virtual_mem = get_function_name(split_line[2]), float(split_line[idx_used_mem])\n", " val = data.get(function_name, (0, 0, used_virtual_mem))\n", " data[function_name] = (val[0], val[1], max(used_virtual_mem, val[2])) \n", " if \"ELAPSED\" in line:\n", " split_line = line.split()\n", " idx_elapsed = split_line.index(\"ELAPSED\") + 2\n", " function_name, elapsed = get_function_name(split_line[2]), float(split_line[idx_elapsed])\n", " val = data.get(function_name, (elapsed, 0, 0))\n", " data[function_name] = (max(elapsed, val[0]), val[1] + 1, val[2])\n", "\n", "values = data.values()\n", "new_data = {\"function_name\": data.keys(), \"elapsed_time\": map(lambda x: x[0], values), \"executions\": map(lambda x: x[1], values), \"used_virtual_mem\": map(lambda x: x[2], values)}\n", " \n", "df = pd.DataFrame(new_data) \n", "\n", "df" ] }, { "cell_type": "code", "execution_count": 55, "metadata": {}, "outputs": [], "source": [ "df[\"total_time\"] = df[\"elapsed_time\"] * df[\"executions\"]" ] }, { "cell_type": "code", "execution_count": 56, "metadata": {}, "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", " \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", " \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", "
elapsed_timeexecutionsfunction_nameused_virtual_memtotal_time
10.1802641Py_kgeneration2877.90.180264
70.1001231generate2877.40.100123
60.0791661fftma22877.90.079166
50.0775141covariance2877.90.077514
20.001184512gasdev2882.60.606208
00.0004561cgrid2877.40.000456
110.0001933fourt2877.90.000579
80.0000983length2877.40.000294
30.000081700cov_value2877.90.056700
100.000037702ran22882.60.025974
90.0000341Py_getvalues0.00.000034
130.0000341prebuild_gwn2877.90.000034
120.0000331build_real2877.90.000033
40.0000151clean_real2877.90.000015
140.0000103maxfactor2877.40.000030
\n", "
" ], "text/plain": [ " elapsed_time executions function_name used_virtual_mem total_time\n", "1 0.180264 1 Py_kgeneration 2877.9 0.180264\n", "7 0.100123 1 generate 2877.4 0.100123\n", "6 0.079166 1 fftma2 2877.9 0.079166\n", "5 0.077514 1 covariance 2877.9 0.077514\n", "2 0.001184 512 gasdev 2882.6 0.606208\n", "0 0.000456 1 cgrid 2877.4 0.000456\n", "11 0.000193 3 fourt 2877.9 0.000579\n", "8 0.000098 3 length 2877.4 0.000294\n", "3 0.000081 700 cov_value 2877.9 0.056700\n", "10 0.000037 702 ran2 2882.6 0.025974\n", "9 0.000034 1 Py_getvalues 0.0 0.000034\n", "13 0.000034 1 prebuild_gwn 2877.9 0.000034\n", "12 0.000033 1 build_real 2877.9 0.000033\n", "4 0.000015 1 clean_real 2877.9 0.000015\n", "14 0.000010 3 maxfactor 2877.4 0.000030" ] }, "execution_count": 56, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.sort_values(by=[\"elapsed_time\"], ascending=False)" ] }, { "cell_type": "code", "execution_count": 57, "metadata": {}, "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", " \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", " \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", "
elapsed_timeexecutionsfunction_nameused_virtual_memtotal_time
20.001184512gasdev2882.60.606208
10.1802641Py_kgeneration2877.90.180264
70.1001231generate2877.40.100123
60.0791661fftma22877.90.079166
50.0775141covariance2877.90.077514
30.000081700cov_value2877.90.056700
100.000037702ran22882.60.025974
110.0001933fourt2877.90.000579
00.0004561cgrid2877.40.000456
80.0000983length2877.40.000294
90.0000341Py_getvalues0.00.000034
130.0000341prebuild_gwn2877.90.000034
120.0000331build_real2877.90.000033
140.0000103maxfactor2877.40.000030
40.0000151clean_real2877.90.000015
\n", "
" ], "text/plain": [ " elapsed_time executions function_name used_virtual_mem total_time\n", "2 0.001184 512 gasdev 2882.6 0.606208\n", "1 0.180264 1 Py_kgeneration 2877.9 0.180264\n", "7 0.100123 1 generate 2877.4 0.100123\n", "6 0.079166 1 fftma2 2877.9 0.079166\n", "5 0.077514 1 covariance 2877.9 0.077514\n", "3 0.000081 700 cov_value 2877.9 0.056700\n", "10 0.000037 702 ran2 2882.6 0.025974\n", "11 0.000193 3 fourt 2877.9 0.000579\n", "0 0.000456 1 cgrid 2877.4 0.000456\n", "8 0.000098 3 length 2877.4 0.000294\n", "9 0.000034 1 Py_getvalues 0.0 0.000034\n", "13 0.000034 1 prebuild_gwn 2877.9 0.000034\n", "12 0.000033 1 build_real 2877.9 0.000033\n", "14 0.000010 3 maxfactor 2877.4 0.000030\n", "4 0.000015 1 clean_real 2877.9 0.000015" ] }, "execution_count": 57, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.sort_values(by=[\"total_time\"], ascending=False)" ] }, { "cell_type": "code", "execution_count": 58, "metadata": {}, "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", " \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", " \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", "
elapsed_timeexecutionsfunction_nameused_virtual_memtotal_time
20.001184512gasdev2882.60.606208
100.000037702ran22882.60.025974
10.1802641Py_kgeneration2877.90.180264
30.000081700cov_value2877.90.056700
40.0000151clean_real2877.90.000015
50.0775141covariance2877.90.077514
60.0791661fftma22877.90.079166
110.0001933fourt2877.90.000579
120.0000331build_real2877.90.000033
130.0000341prebuild_gwn2877.90.000034
00.0004561cgrid2877.40.000456
70.1001231generate2877.40.100123
80.0000983length2877.40.000294
140.0000103maxfactor2877.40.000030
90.0000341Py_getvalues0.00.000034
\n", "
" ], "text/plain": [ " elapsed_time executions function_name used_virtual_mem total_time\n", "2 0.001184 512 gasdev 2882.6 0.606208\n", "10 0.000037 702 ran2 2882.6 0.025974\n", "1 0.180264 1 Py_kgeneration 2877.9 0.180264\n", "3 0.000081 700 cov_value 2877.9 0.056700\n", "4 0.000015 1 clean_real 2877.9 0.000015\n", "5 0.077514 1 covariance 2877.9 0.077514\n", "6 0.079166 1 fftma2 2877.9 0.079166\n", "11 0.000193 3 fourt 2877.9 0.000579\n", "12 0.000033 1 build_real 2877.9 0.000033\n", "13 0.000034 1 prebuild_gwn 2877.9 0.000034\n", "0 0.000456 1 cgrid 2877.4 0.000456\n", "7 0.100123 1 generate 2877.4 0.100123\n", "8 0.000098 3 length 2877.4 0.000294\n", "14 0.000010 3 maxfactor 2877.4 0.000030\n", "9 0.000034 1 Py_getvalues 0.0 0.000034" ] }, "execution_count": 58, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.sort_values(by=[\"used_virtual_mem\"], ascending=False)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#Import libraries\n", "from matplotlib_venn import venn3\n", "from matplotlib import pyplot as plt\n", "%matplotlib inline" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "relations = {\n", " \"generate\": [\"gasdev\"],\n", " \"fftma2\": [\"covariance\", \"fourt\", \"prebuild_gwn\"]\n", "}" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "\n", "plt.figure(dpi=125)\n", "set_a = set([0.023829, 0.010957, 0.012503])\n", "\n", "set_b = set([0.010957])\n", "\n", "set_c = set([0.012503])\n", "\n", "venn3([set_a, set_b, set_c], ('Py_kgeneration', 'generate', 'fftma2'))\n", "plt.show()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "venn3([set(['Py_kgeneration', 'generate', 'fftma2']), set(['generate', 'fftma2']), set(['fftma2'])])" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import matplotlib.pyplot as plt" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plt.figure(dpi=125)\n", "plt.title('Py_kgeneration')\n", "plt.pie([0.010957, 0.012503], labels=[\"generate\", \"fftma2\"], normalize=True)\n", "plt.show()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Import libraries\n", "from matplotlib import pyplot as plt\n", "import numpy as np\n", "\n", "\n", "# Creating dataset\n", "size = 6\n", "cars = ['AUDI', 'BMW', 'FORD',\n", "\t\t'TESLA', 'JAGUAR', 'MERCEDES']\n", "\n", "data = np.array([[23, 16], [17, 23],\n", "\t\t\t\t[35, 11], [29, 33],\n", "\t\t\t\t[12, 27], [41, 42]])\n", "\n", "# normalizing data to 2 pi\n", "norm = data / np.sum(data)*2 * np.pi\n", "\n", "# obtaining ordinates of bar edges\n", "left = np.cumsum(np.append(0,\n", "\t\t\t\t\t\tnorm.flatten()[:-1])).reshape(data.shape)\n", "\n", "# Creating color scale\n", "cmap = plt.get_cmap(\"tab20c\")\n", "outer_colors = cmap(np.arange(6)*4)\n", "inner_colors = cmap(np.array([1, 2, 5, 6, 9,\n", "\t\t\t\t\t\t\t10, 12, 13, 15,\n", "\t\t\t\t\t\t\t17, 18, 20 ]))\n", "\n", "# Creating plot\n", "fig, ax = plt.subplots(figsize =(10, 7),\n", "\t\t\t\t\tsubplot_kw = dict(polar = True))\n", "\n", "ax.bar(x = left[:, 0],\n", "\twidth = norm.sum(axis = 1),\n", "\tbottom = 1-size,\n", "\theight = size,\n", "\tcolor = outer_colors,\n", "\tedgecolor ='w',\n", "\tlinewidth = 1,\n", "\talign =\"edge\")\n", "\n", "ax.bar(x = left.flatten(),\n", "\twidth = norm.flatten(),\n", "\tbottom = 1-2 * size,\n", "\theight = size,\n", "\tcolor = inner_colors,\n", "\tedgecolor ='w',\n", "\tlinewidth = 1,\n", "\talign =\"edge\")\n", "\n", "ax.set(title =\"Nested pie chart\")\n", "ax.set_axis_off()\n", "\n", "# show plot\n", "plt.show()\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "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.18" } }, "nbformat": 4, "nbformat_minor": 2 }