{
"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",
" elapsed_time | \n",
" executions | \n",
" function_name | \n",
" used_virtual_mem | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" 0.000456 | \n",
" 1 | \n",
" cgrid | \n",
" 2877.4 | \n",
"
\n",
" \n",
" 1 | \n",
" 0.180264 | \n",
" 1 | \n",
" Py_kgeneration | \n",
" 2877.9 | \n",
"
\n",
" \n",
" 2 | \n",
" 0.001184 | \n",
" 512 | \n",
" gasdev | \n",
" 2882.6 | \n",
"
\n",
" \n",
" 3 | \n",
" 0.000081 | \n",
" 700 | \n",
" cov_value | \n",
" 2877.9 | \n",
"
\n",
" \n",
" 4 | \n",
" 0.000015 | \n",
" 1 | \n",
" clean_real | \n",
" 2877.9 | \n",
"
\n",
" \n",
" 5 | \n",
" 0.077514 | \n",
" 1 | \n",
" covariance | \n",
" 2877.9 | \n",
"
\n",
" \n",
" 6 | \n",
" 0.079166 | \n",
" 1 | \n",
" fftma2 | \n",
" 2877.9 | \n",
"
\n",
" \n",
" 7 | \n",
" 0.100123 | \n",
" 1 | \n",
" generate | \n",
" 2877.4 | \n",
"
\n",
" \n",
" 8 | \n",
" 0.000098 | \n",
" 3 | \n",
" length | \n",
" 2877.4 | \n",
"
\n",
" \n",
" 9 | \n",
" 0.000034 | \n",
" 1 | \n",
" Py_getvalues | \n",
" 0.0 | \n",
"
\n",
" \n",
" 10 | \n",
" 0.000037 | \n",
" 702 | \n",
" ran2 | \n",
" 2882.6 | \n",
"
\n",
" \n",
" 11 | \n",
" 0.000193 | \n",
" 3 | \n",
" fourt | \n",
" 2877.9 | \n",
"
\n",
" \n",
" 12 | \n",
" 0.000033 | \n",
" 1 | \n",
" build_real | \n",
" 2877.9 | \n",
"
\n",
" \n",
" 13 | \n",
" 0.000034 | \n",
" 1 | \n",
" prebuild_gwn | \n",
" 2877.9 | \n",
"
\n",
" \n",
" 14 | \n",
" 0.000010 | \n",
" 3 | \n",
" maxfactor | \n",
" 2877.4 | \n",
"
\n",
" \n",
"
\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",
" elapsed_time | \n",
" executions | \n",
" function_name | \n",
" used_virtual_mem | \n",
" total_time | \n",
"
\n",
" \n",
" \n",
" \n",
" 1 | \n",
" 0.180264 | \n",
" 1 | \n",
" Py_kgeneration | \n",
" 2877.9 | \n",
" 0.180264 | \n",
"
\n",
" \n",
" 7 | \n",
" 0.100123 | \n",
" 1 | \n",
" generate | \n",
" 2877.4 | \n",
" 0.100123 | \n",
"
\n",
" \n",
" 6 | \n",
" 0.079166 | \n",
" 1 | \n",
" fftma2 | \n",
" 2877.9 | \n",
" 0.079166 | \n",
"
\n",
" \n",
" 5 | \n",
" 0.077514 | \n",
" 1 | \n",
" covariance | \n",
" 2877.9 | \n",
" 0.077514 | \n",
"
\n",
" \n",
" 2 | \n",
" 0.001184 | \n",
" 512 | \n",
" gasdev | \n",
" 2882.6 | \n",
" 0.606208 | \n",
"
\n",
" \n",
" 0 | \n",
" 0.000456 | \n",
" 1 | \n",
" cgrid | \n",
" 2877.4 | \n",
" 0.000456 | \n",
"
\n",
" \n",
" 11 | \n",
" 0.000193 | \n",
" 3 | \n",
" fourt | \n",
" 2877.9 | \n",
" 0.000579 | \n",
"
\n",
" \n",
" 8 | \n",
" 0.000098 | \n",
" 3 | \n",
" length | \n",
" 2877.4 | \n",
" 0.000294 | \n",
"
\n",
" \n",
" 3 | \n",
" 0.000081 | \n",
" 700 | \n",
" cov_value | \n",
" 2877.9 | \n",
" 0.056700 | \n",
"
\n",
" \n",
" 10 | \n",
" 0.000037 | \n",
" 702 | \n",
" ran2 | \n",
" 2882.6 | \n",
" 0.025974 | \n",
"
\n",
" \n",
" 9 | \n",
" 0.000034 | \n",
" 1 | \n",
" Py_getvalues | \n",
" 0.0 | \n",
" 0.000034 | \n",
"
\n",
" \n",
" 13 | \n",
" 0.000034 | \n",
" 1 | \n",
" prebuild_gwn | \n",
" 2877.9 | \n",
" 0.000034 | \n",
"
\n",
" \n",
" 12 | \n",
" 0.000033 | \n",
" 1 | \n",
" build_real | \n",
" 2877.9 | \n",
" 0.000033 | \n",
"
\n",
" \n",
" 4 | \n",
" 0.000015 | \n",
" 1 | \n",
" clean_real | \n",
" 2877.9 | \n",
" 0.000015 | \n",
"
\n",
" \n",
" 14 | \n",
" 0.000010 | \n",
" 3 | \n",
" maxfactor | \n",
" 2877.4 | \n",
" 0.000030 | \n",
"
\n",
" \n",
"
\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",
" elapsed_time | \n",
" executions | \n",
" function_name | \n",
" used_virtual_mem | \n",
" total_time | \n",
"
\n",
" \n",
" \n",
" \n",
" 2 | \n",
" 0.001184 | \n",
" 512 | \n",
" gasdev | \n",
" 2882.6 | \n",
" 0.606208 | \n",
"
\n",
" \n",
" 1 | \n",
" 0.180264 | \n",
" 1 | \n",
" Py_kgeneration | \n",
" 2877.9 | \n",
" 0.180264 | \n",
"
\n",
" \n",
" 7 | \n",
" 0.100123 | \n",
" 1 | \n",
" generate | \n",
" 2877.4 | \n",
" 0.100123 | \n",
"
\n",
" \n",
" 6 | \n",
" 0.079166 | \n",
" 1 | \n",
" fftma2 | \n",
" 2877.9 | \n",
" 0.079166 | \n",
"
\n",
" \n",
" 5 | \n",
" 0.077514 | \n",
" 1 | \n",
" covariance | \n",
" 2877.9 | \n",
" 0.077514 | \n",
"
\n",
" \n",
" 3 | \n",
" 0.000081 | \n",
" 700 | \n",
" cov_value | \n",
" 2877.9 | \n",
" 0.056700 | \n",
"
\n",
" \n",
" 10 | \n",
" 0.000037 | \n",
" 702 | \n",
" ran2 | \n",
" 2882.6 | \n",
" 0.025974 | \n",
"
\n",
" \n",
" 11 | \n",
" 0.000193 | \n",
" 3 | \n",
" fourt | \n",
" 2877.9 | \n",
" 0.000579 | \n",
"
\n",
" \n",
" 0 | \n",
" 0.000456 | \n",
" 1 | \n",
" cgrid | \n",
" 2877.4 | \n",
" 0.000456 | \n",
"
\n",
" \n",
" 8 | \n",
" 0.000098 | \n",
" 3 | \n",
" length | \n",
" 2877.4 | \n",
" 0.000294 | \n",
"
\n",
" \n",
" 9 | \n",
" 0.000034 | \n",
" 1 | \n",
" Py_getvalues | \n",
" 0.0 | \n",
" 0.000034 | \n",
"
\n",
" \n",
" 13 | \n",
" 0.000034 | \n",
" 1 | \n",
" prebuild_gwn | \n",
" 2877.9 | \n",
" 0.000034 | \n",
"
\n",
" \n",
" 12 | \n",
" 0.000033 | \n",
" 1 | \n",
" build_real | \n",
" 2877.9 | \n",
" 0.000033 | \n",
"
\n",
" \n",
" 14 | \n",
" 0.000010 | \n",
" 3 | \n",
" maxfactor | \n",
" 2877.4 | \n",
" 0.000030 | \n",
"
\n",
" \n",
" 4 | \n",
" 0.000015 | \n",
" 1 | \n",
" clean_real | \n",
" 2877.9 | \n",
" 0.000015 | \n",
"
\n",
" \n",
"
\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",
" elapsed_time | \n",
" executions | \n",
" function_name | \n",
" used_virtual_mem | \n",
" total_time | \n",
"
\n",
" \n",
" \n",
" \n",
" 2 | \n",
" 0.001184 | \n",
" 512 | \n",
" gasdev | \n",
" 2882.6 | \n",
" 0.606208 | \n",
"
\n",
" \n",
" 10 | \n",
" 0.000037 | \n",
" 702 | \n",
" ran2 | \n",
" 2882.6 | \n",
" 0.025974 | \n",
"
\n",
" \n",
" 1 | \n",
" 0.180264 | \n",
" 1 | \n",
" Py_kgeneration | \n",
" 2877.9 | \n",
" 0.180264 | \n",
"
\n",
" \n",
" 3 | \n",
" 0.000081 | \n",
" 700 | \n",
" cov_value | \n",
" 2877.9 | \n",
" 0.056700 | \n",
"
\n",
" \n",
" 4 | \n",
" 0.000015 | \n",
" 1 | \n",
" clean_real | \n",
" 2877.9 | \n",
" 0.000015 | \n",
"
\n",
" \n",
" 5 | \n",
" 0.077514 | \n",
" 1 | \n",
" covariance | \n",
" 2877.9 | \n",
" 0.077514 | \n",
"
\n",
" \n",
" 6 | \n",
" 0.079166 | \n",
" 1 | \n",
" fftma2 | \n",
" 2877.9 | \n",
" 0.079166 | \n",
"
\n",
" \n",
" 11 | \n",
" 0.000193 | \n",
" 3 | \n",
" fourt | \n",
" 2877.9 | \n",
" 0.000579 | \n",
"
\n",
" \n",
" 12 | \n",
" 0.000033 | \n",
" 1 | \n",
" build_real | \n",
" 2877.9 | \n",
" 0.000033 | \n",
"
\n",
" \n",
" 13 | \n",
" 0.000034 | \n",
" 1 | \n",
" prebuild_gwn | \n",
" 2877.9 | \n",
" 0.000034 | \n",
"
\n",
" \n",
" 0 | \n",
" 0.000456 | \n",
" 1 | \n",
" cgrid | \n",
" 2877.4 | \n",
" 0.000456 | \n",
"
\n",
" \n",
" 7 | \n",
" 0.100123 | \n",
" 1 | \n",
" generate | \n",
" 2877.4 | \n",
" 0.100123 | \n",
"
\n",
" \n",
" 8 | \n",
" 0.000098 | \n",
" 3 | \n",
" length | \n",
" 2877.4 | \n",
" 0.000294 | \n",
"
\n",
" \n",
" 14 | \n",
" 0.000010 | \n",
" 3 | \n",
" maxfactor | \n",
" 2877.4 | \n",
" 0.000030 | \n",
"
\n",
" \n",
" 9 | \n",
" 0.000034 | \n",
" 1 | \n",
" Py_getvalues | \n",
" 0.0 | \n",
" 0.000034 | \n",
"
\n",
" \n",
"
\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
}