{ "cells": [ { "cell_type": "code", "execution_count": 56, "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "import matplotlib.pyplot as plt\n", "import numpy as np " ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [], "source": [ "def get_function_name(function_name):\n", " return function_name[10:].rsplit(\".c\")[0]" ] }, { "cell_type": "code", "execution_count": 28, "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", "
function_nameelapsed_timeexecutionsused_virtual_mem
0Py_getvalues0.00000710.0
1ran20.00006541552240.5
2gasdev0.00038332768240.5
3generate2.0550151219.2
4maxfactor0.0000055219.2
5length0.0000713219.2
6cgrid0.0002651219.2
7cov_value0.00015624624234.7
8covariance0.8397371228.0
9fourt0.0034513227.9
10prebuild_gwn0.0001381227.4
11build_real0.0004241227.4
12clean_real0.0001581227.4
13fftma20.8492711227.4
14Py_kgeneration2.9046261227.4
\n", "
" ], "text/plain": [ " function_name elapsed_time executions used_virtual_mem\n", "0 Py_getvalues 0.000007 1 0.0\n", "1 ran2 0.000065 41552 240.5\n", "2 gasdev 0.000383 32768 240.5\n", "3 generate 2.055015 1 219.2\n", "4 maxfactor 0.000005 5 219.2\n", "5 length 0.000071 3 219.2\n", "6 cgrid 0.000265 1 219.2\n", "7 cov_value 0.000156 24624 234.7\n", "8 covariance 0.839737 1 228.0\n", "9 fourt 0.003451 3 227.9\n", "10 prebuild_gwn 0.000138 1 227.4\n", "11 build_real 0.000424 1 227.4\n", "12 clean_real 0.000158 1 227.4\n", "13 fftma2 0.849271 1 227.4\n", "14 Py_kgeneration 2.904626 1 227.4" ] }, "execution_count": 28, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data = {}\n", "with open(\"log_32.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": 27, "metadata": {}, "outputs": [], "source": [ "df[\"total_time\"] = df[\"elapsed_time\"] * df[\"executions\"]" ] }, { "cell_type": "code", "execution_count": 25, "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", "
function_nameelapsed_timeexecutionsused_virtual_memtotal_time
2gasdev0.00038332768240.512.550144
7cov_value0.00015624624234.73.841344
14Py_kgeneration2.9046261227.42.904626
1ran20.00006541552240.52.700880
3generate2.0550151219.22.055015
13fftma20.8492711227.40.849271
8covariance0.8397371228.00.839737
9fourt0.0034513227.90.010353
11build_real0.0004241227.40.000424
6cgrid0.0002651219.20.000265
5length0.0000713219.20.000213
12clean_real0.0001581227.40.000158
10prebuild_gwn0.0001381227.40.000138
4maxfactor0.0000055219.20.000025
0Py_getvalues0.00000710.00.000007
\n", "
" ], "text/plain": [ " function_name elapsed_time executions used_virtual_mem total_time\n", "2 gasdev 0.000383 32768 240.5 12.550144\n", "7 cov_value 0.000156 24624 234.7 3.841344\n", "14 Py_kgeneration 2.904626 1 227.4 2.904626\n", "1 ran2 0.000065 41552 240.5 2.700880\n", "3 generate 2.055015 1 219.2 2.055015\n", "13 fftma2 0.849271 1 227.4 0.849271\n", "8 covariance 0.839737 1 228.0 0.839737\n", "9 fourt 0.003451 3 227.9 0.010353\n", "11 build_real 0.000424 1 227.4 0.000424\n", "6 cgrid 0.000265 1 219.2 0.000265\n", "5 length 0.000071 3 219.2 0.000213\n", "12 clean_real 0.000158 1 227.4 0.000158\n", "10 prebuild_gwn 0.000138 1 227.4 0.000138\n", "4 maxfactor 0.000005 5 219.2 0.000025\n", "0 Py_getvalues 0.000007 1 0.0 0.000007" ] }, "execution_count": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.sort_values(by=[\"total_time\", \"used_virtual_mem\"], ascending=False)" ] }, { "cell_type": "code", "execution_count": 21, "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", "
function_nameelapsed_timeexecutionsused_virtual_memtotal_time
1ran20.000220333450548.273.359000
2gasdev0.000707262144548.2185.335808
3generate20.6874901425.620.687490
4maxfactor0.0000054425.60.000020
5length0.0000593425.60.000177
6cgrid0.0001991425.60.000199
7cov_value0.000158156816425.624.776928
8covariance7.8137951313.07.813795
12clean_real0.0009661311.30.000966
14Py_kgeneration28.6760721311.328.676072
9fourt0.0690883311.10.207264
10prebuild_gwn0.0016241308.70.001624
11build_real0.0042941308.40.004294
13fftma27.9882121308.47.988212
0Py_getvalues0.00000910.00.000009
\n", "
" ], "text/plain": [ " function_name elapsed_time executions used_virtual_mem total_time\n", "1 ran2 0.000220 333450 548.2 73.359000\n", "2 gasdev 0.000707 262144 548.2 185.335808\n", "3 generate 20.687490 1 425.6 20.687490\n", "4 maxfactor 0.000005 4 425.6 0.000020\n", "5 length 0.000059 3 425.6 0.000177\n", "6 cgrid 0.000199 1 425.6 0.000199\n", "7 cov_value 0.000158 156816 425.6 24.776928\n", "8 covariance 7.813795 1 313.0 7.813795\n", "12 clean_real 0.000966 1 311.3 0.000966\n", "14 Py_kgeneration 28.676072 1 311.3 28.676072\n", "9 fourt 0.069088 3 311.1 0.207264\n", "10 prebuild_gwn 0.001624 1 308.7 0.001624\n", "11 build_real 0.004294 1 308.4 0.004294\n", "13 fftma2 7.988212 1 308.4 7.988212\n", "0 Py_getvalues 0.000009 1 0.0 0.000009" ] }, "execution_count": 21, "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": [] }, { "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": 87, "metadata": {}, "outputs": [], "source": [ "data = []\n", "with open(\"log_64.txt\") as log_file:\n", " lines = log_file.readlines()\n", " \n", " for line in lines:\n", " row = {}\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", "\n", " row[\"function\"] = function_name\n", " row[\"memory\"] = used_virtual_mem \n", "\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].rsplit(\",\")[0])\n", " #val = data.get(function_name, (elapsed, 0, 0))\n", " #data[function_name] = (max(elapsed, val[0]), val[1] + 1, val[2])\n", " #data.append({\"function\": function_name, \"time\": elapsed, \"memory\": 0})\n", " row[\"function\"] = function_name\n", " row[\"time\"] = elapsed\n", "\n", " if row: data.append(row)" ] }, { "cell_type": "code", "execution_count": 88, "metadata": {}, "outputs": [], "source": [ "df2 = pd.DataFrame(data) " ] }, { "cell_type": "code", "execution_count": 89, "metadata": {}, "outputs": [], "source": [ "df2 = df2.fillna(np.nan)" ] }, { "cell_type": "code", "execution_count": 90, "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", "
functiontimememory
0Py_getvalues0.000008NaN
1ran20.0000030.0
2ran20.0000230.0
3gasdev0.0000460.0
4gasdev0.0000060.0
\n", "
" ], "text/plain": [ " function time memory\n", "0 Py_getvalues 0.000008 NaN\n", "1 ran2 0.000003 0.0\n", "2 ran2 0.000023 0.0\n", "3 gasdev 0.000046 0.0\n", "4 gasdev 0.000006 0.0" ] }, "execution_count": 90, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df2.head()" ] }, { "cell_type": "code", "execution_count": 91, "metadata": {}, "outputs": [], "source": [ "df2_grouped = df2.groupby(['function']).agg({'time': ['min', 'max', 'mean', 'sum', 'count'], 'memory': ['min', 'max', 'median']})" ] }, { "cell_type": "code", "execution_count": 92, "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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
timememory
minmaxmeansumcountminmaxmedian
function
Py_kgeneration11.31662111.31662111.31662111.3166211-293.7-293.7-293.7
generate7.4248317.4248317.4248317.4248311-226.3-226.3-226.3
gasdev0.0000030.0002770.0000215.484581262144-20.05.30.0
fftma23.8914313.8914313.8914313.8914311-69.5-69.5-69.5
covariance3.7657313.7657313.7657313.7657311-65.0-65.0-65.0
cov_value0.0000070.0001080.0000132.062640156816-1.91.50.0
ran20.0000020.0001140.0000051.534732333450-19.72.60.0
fourt0.0327780.0515450.0396640.1189913-1.9-0.0-0.2
build_real0.0040530.0040530.0040530.00405310.00.00.0
prebuild_gwn0.0011320.0011320.0011320.0011321-2.5-2.5-2.5
clean_real0.0008300.0008300.0008300.0008301-0.7-0.7-0.7
cgrid0.0001480.0001480.0001480.00014810.00.00.0
length0.0000150.0000640.0000390.00011830.00.00.0
maxfactor0.0000040.0000250.0000110.00004340.00.00.0
Py_getvalues0.0000080.0000080.0000080.0000081NaNNaNNaN
\n", "
" ], "text/plain": [ " time memory \\\n", " min max mean sum count min \n", "function \n", "Py_kgeneration 11.316621 11.316621 11.316621 11.316621 1 -293.7 \n", "generate 7.424831 7.424831 7.424831 7.424831 1 -226.3 \n", "gasdev 0.000003 0.000277 0.000021 5.484581 262144 -20.0 \n", "fftma2 3.891431 3.891431 3.891431 3.891431 1 -69.5 \n", "covariance 3.765731 3.765731 3.765731 3.765731 1 -65.0 \n", "cov_value 0.000007 0.000108 0.000013 2.062640 156816 -1.9 \n", "ran2 0.000002 0.000114 0.000005 1.534732 333450 -19.7 \n", "fourt 0.032778 0.051545 0.039664 0.118991 3 -1.9 \n", "build_real 0.004053 0.004053 0.004053 0.004053 1 0.0 \n", "prebuild_gwn 0.001132 0.001132 0.001132 0.001132 1 -2.5 \n", "clean_real 0.000830 0.000830 0.000830 0.000830 1 -0.7 \n", "cgrid 0.000148 0.000148 0.000148 0.000148 1 0.0 \n", "length 0.000015 0.000064 0.000039 0.000118 3 0.0 \n", "maxfactor 0.000004 0.000025 0.000011 0.000043 4 0.0 \n", "Py_getvalues 0.000008 0.000008 0.000008 0.000008 1 NaN \n", "\n", " \n", " max median \n", "function \n", "Py_kgeneration -293.7 -293.7 \n", "generate -226.3 -226.3 \n", "gasdev 5.3 0.0 \n", "fftma2 -69.5 -69.5 \n", "covariance -65.0 -65.0 \n", "cov_value 1.5 0.0 \n", "ran2 2.6 0.0 \n", "fourt -0.0 -0.2 \n", "build_real 0.0 0.0 \n", "prebuild_gwn -2.5 -2.5 \n", "clean_real -0.7 -0.7 \n", "cgrid 0.0 0.0 \n", "length 0.0 0.0 \n", "maxfactor 0.0 0.0 \n", "Py_getvalues NaN NaN " ] }, "execution_count": 92, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df2_grouped.sort_values(by=('time', 'sum'), ascending=False)" ] }, { "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 }