{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd "
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['12:30:24', 'INFO', './lib_src/generate.c:61:', 'TOTAL', 'VIRTUAL', 'MEM', '=', '7683.0', 'MB,', 'USED', 'VIRTUAL', 'MEM', '=', '304.2', 'MB,', 'USED', 'VIRTUAL', 'MEM', 'BY', 'CURRENT', 'PROCESS', '=', '1072', 'MB']\n",
"['12:30:24', 'INFO', './lib_src/Py_kgeneration.c:64:', 'TOTAL', 'VIRTUAL', 'MEM', '=', '7683.0', 'MB,', 'USED', 'VIRTUAL', 'MEM', '=', '303.6', 'MB,', 'USED', 'VIRTUAL', 'MEM', 'BY', 'CURRENT', 'PROCESS', '=', '1072', 'MB']\n"
]
},
{
"data": {
"text/html": [
"
\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" function_name | \n",
" elapsed_time | \n",
" executions | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" ./lib_src/Py_getvalues.c:157: | \n",
" 0.000007 | \n",
" 1 | \n",
"
\n",
" \n",
" 1 | \n",
" ./lib_src/ran2.c:68: | \n",
" 0.000004 | \n",
" 142 | \n",
"
\n",
" \n",
" 2 | \n",
" ./lib_src/gasdev.c:35: | \n",
" 0.000023 | \n",
" 151 | \n",
"
\n",
" \n",
" 3 | \n",
" ./lib_src/gasdev.c:43: | \n",
" 0.000003 | \n",
" 202 | \n",
"
\n",
" \n",
" 4 | \n",
" ./lib_src/generate.c:75: | \n",
" 0.010957 | \n",
" 1 | \n",
"
\n",
" \n",
" 5 | \n",
" ./lib_src/maxfactor.c:42: | \n",
" 0.000004 | \n",
" 1 | \n",
"
\n",
" \n",
" 6 | \n",
" ./lib_src/length.c:47: | \n",
" 0.000013 | \n",
" 1 | \n",
"
\n",
" \n",
" 7 | \n",
" ./lib_src/cgrid.c:50: | \n",
" 0.000060 | \n",
" 1 | \n",
"
\n",
" \n",
" 8 | \n",
" ./lib_src/cov_value.c:60: | \n",
" 0.000011 | \n",
" 76 | \n",
"
\n",
" \n",
" 9 | \n",
" ./lib_src/covariance.c:86: | \n",
" 0.012162 | \n",
" 1 | \n",
"
\n",
" \n",
" 10 | \n",
" ./lib_src/fourt.c:593: | \n",
" 0.000065 | \n",
" 2 | \n",
"
\n",
" \n",
" 11 | \n",
" ./lib_src/prebuild_gwn.c:57: | \n",
" 0.000009 | \n",
" 1 | \n",
"
\n",
" \n",
" 12 | \n",
" ./lib_src/build_real.c:50: | \n",
" 0.000019 | \n",
" 1 | \n",
"
\n",
" \n",
" 13 | \n",
" ./lib_src/clean_real.c:48: | \n",
" 0.000007 | \n",
" 1 | \n",
"
\n",
" \n",
" 14 | \n",
" ./lib_src/fftma2.c:106: | \n",
" 0.012503 | \n",
" 1 | \n",
"
\n",
" \n",
" 15 | \n",
" ./lib_src/Py_kgeneration.c:74: | \n",
" 0.023829 | \n",
" 1 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" function_name elapsed_time executions\n",
"0 ./lib_src/Py_getvalues.c:157: 0.000007 1\n",
"1 ./lib_src/ran2.c:68: 0.000004 142\n",
"2 ./lib_src/gasdev.c:35: 0.000023 151\n",
"3 ./lib_src/gasdev.c:43: 0.000003 202\n",
"4 ./lib_src/generate.c:75: 0.010957 1\n",
"5 ./lib_src/maxfactor.c:42: 0.000004 1\n",
"6 ./lib_src/length.c:47: 0.000013 1\n",
"7 ./lib_src/cgrid.c:50: 0.000060 1\n",
"8 ./lib_src/cov_value.c:60: 0.000011 76\n",
"9 ./lib_src/covariance.c:86: 0.012162 1\n",
"10 ./lib_src/fourt.c:593: 0.000065 2\n",
"11 ./lib_src/prebuild_gwn.c:57: 0.000009 1\n",
"12 ./lib_src/build_real.c:50: 0.000019 1\n",
"13 ./lib_src/clean_real.c:48: 0.000007 1\n",
"14 ./lib_src/fftma2.c:106: 0.012503 1\n",
"15 ./lib_src/Py_kgeneration.c:74: 0.023829 1"
]
},
"execution_count": 3,
"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",
" print(split_line)\n",
" if \"ELAPSED\" in line:\n",
" split_line = line.split()\n",
" idx_elapsed = split_line.index(\"ELAPSED\") + 2\n",
" function_name, elapsed = split_line[2], float(split_line[idx_elapsed])\n",
" if function_name not in data or (function_name in data and elapsed > data[function_name][0]):\n",
" val = data.get(function_name, (elapsed, 0))\n",
" data[function_name] = (val[0], val[1] + 1)\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)}\n",
" \n",
"df = pd.DataFrame(new_data) \n",
"\n",
"df"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"df[\"total_time\"] = df[\"elapsed_time\"] * df[\"executions\"]"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" function_name | \n",
" elapsed_time | \n",
" executions | \n",
" total_time | \n",
"
\n",
" \n",
" \n",
" \n",
" 15 | \n",
" ./lib_src/Py_kgeneration.c:74: | \n",
" 0.023829 | \n",
" 1 | \n",
" 0.023829 | \n",
"
\n",
" \n",
" 14 | \n",
" ./lib_src/fftma2.c:106: | \n",
" 0.012503 | \n",
" 1 | \n",
" 0.012503 | \n",
"
\n",
" \n",
" 9 | \n",
" ./lib_src/covariance.c:86: | \n",
" 0.012162 | \n",
" 1 | \n",
" 0.012162 | \n",
"
\n",
" \n",
" 4 | \n",
" ./lib_src/generate.c:75: | \n",
" 0.010957 | \n",
" 1 | \n",
" 0.010957 | \n",
"
\n",
" \n",
" 10 | \n",
" ./lib_src/fourt.c:593: | \n",
" 0.000065 | \n",
" 2 | \n",
" 0.000130 | \n",
"
\n",
" \n",
" 7 | \n",
" ./lib_src/cgrid.c:50: | \n",
" 0.000060 | \n",
" 1 | \n",
" 0.000060 | \n",
"
\n",
" \n",
" 2 | \n",
" ./lib_src/gasdev.c:35: | \n",
" 0.000023 | \n",
" 151 | \n",
" 0.003473 | \n",
"
\n",
" \n",
" 12 | \n",
" ./lib_src/build_real.c:50: | \n",
" 0.000019 | \n",
" 1 | \n",
" 0.000019 | \n",
"
\n",
" \n",
" 6 | \n",
" ./lib_src/length.c:47: | \n",
" 0.000013 | \n",
" 1 | \n",
" 0.000013 | \n",
"
\n",
" \n",
" 8 | \n",
" ./lib_src/cov_value.c:60: | \n",
" 0.000011 | \n",
" 76 | \n",
" 0.000836 | \n",
"
\n",
" \n",
" 11 | \n",
" ./lib_src/prebuild_gwn.c:57: | \n",
" 0.000009 | \n",
" 1 | \n",
" 0.000009 | \n",
"
\n",
" \n",
" 0 | \n",
" ./lib_src/Py_getvalues.c:157: | \n",
" 0.000007 | \n",
" 1 | \n",
" 0.000007 | \n",
"
\n",
" \n",
" 13 | \n",
" ./lib_src/clean_real.c:48: | \n",
" 0.000007 | \n",
" 1 | \n",
" 0.000007 | \n",
"
\n",
" \n",
" 1 | \n",
" ./lib_src/ran2.c:68: | \n",
" 0.000004 | \n",
" 142 | \n",
" 0.000568 | \n",
"
\n",
" \n",
" 5 | \n",
" ./lib_src/maxfactor.c:42: | \n",
" 0.000004 | \n",
" 1 | \n",
" 0.000004 | \n",
"
\n",
" \n",
" 3 | \n",
" ./lib_src/gasdev.c:43: | \n",
" 0.000003 | \n",
" 202 | \n",
" 0.000606 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" function_name elapsed_time executions total_time\n",
"15 ./lib_src/Py_kgeneration.c:74: 0.023829 1 0.023829\n",
"14 ./lib_src/fftma2.c:106: 0.012503 1 0.012503\n",
"9 ./lib_src/covariance.c:86: 0.012162 1 0.012162\n",
"4 ./lib_src/generate.c:75: 0.010957 1 0.010957\n",
"10 ./lib_src/fourt.c:593: 0.000065 2 0.000130\n",
"7 ./lib_src/cgrid.c:50: 0.000060 1 0.000060\n",
"2 ./lib_src/gasdev.c:35: 0.000023 151 0.003473\n",
"12 ./lib_src/build_real.c:50: 0.000019 1 0.000019\n",
"6 ./lib_src/length.c:47: 0.000013 1 0.000013\n",
"8 ./lib_src/cov_value.c:60: 0.000011 76 0.000836\n",
"11 ./lib_src/prebuild_gwn.c:57: 0.000009 1 0.000009\n",
"0 ./lib_src/Py_getvalues.c:157: 0.000007 1 0.000007\n",
"13 ./lib_src/clean_real.c:48: 0.000007 1 0.000007\n",
"1 ./lib_src/ran2.c:68: 0.000004 142 0.000568\n",
"5 ./lib_src/maxfactor.c:42: 0.000004 1 0.000004\n",
"3 ./lib_src/gasdev.c:43: 0.000003 202 0.000606"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.sort_values(by=[\"elapsed_time\"], ascending=False)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" function_name | \n",
" elapsed_time | \n",
" executions | \n",
" total_time | \n",
"
\n",
" \n",
" \n",
" \n",
" 15 | \n",
" ./lib_src/Py_kgeneration.c:74: | \n",
" 0.023829 | \n",
" 1 | \n",
" 0.023829 | \n",
"
\n",
" \n",
" 14 | \n",
" ./lib_src/fftma2.c:106: | \n",
" 0.012503 | \n",
" 1 | \n",
" 0.012503 | \n",
"
\n",
" \n",
" 9 | \n",
" ./lib_src/covariance.c:86: | \n",
" 0.012162 | \n",
" 1 | \n",
" 0.012162 | \n",
"
\n",
" \n",
" 4 | \n",
" ./lib_src/generate.c:75: | \n",
" 0.010957 | \n",
" 1 | \n",
" 0.010957 | \n",
"
\n",
" \n",
" 2 | \n",
" ./lib_src/gasdev.c:35: | \n",
" 0.000023 | \n",
" 151 | \n",
" 0.003473 | \n",
"
\n",
" \n",
" 8 | \n",
" ./lib_src/cov_value.c:60: | \n",
" 0.000011 | \n",
" 76 | \n",
" 0.000836 | \n",
"
\n",
" \n",
" 3 | \n",
" ./lib_src/gasdev.c:43: | \n",
" 0.000003 | \n",
" 202 | \n",
" 0.000606 | \n",
"
\n",
" \n",
" 1 | \n",
" ./lib_src/ran2.c:68: | \n",
" 0.000004 | \n",
" 142 | \n",
" 0.000568 | \n",
"
\n",
" \n",
" 10 | \n",
" ./lib_src/fourt.c:593: | \n",
" 0.000065 | \n",
" 2 | \n",
" 0.000130 | \n",
"
\n",
" \n",
" 7 | \n",
" ./lib_src/cgrid.c:50: | \n",
" 0.000060 | \n",
" 1 | \n",
" 0.000060 | \n",
"
\n",
" \n",
" 12 | \n",
" ./lib_src/build_real.c:50: | \n",
" 0.000019 | \n",
" 1 | \n",
" 0.000019 | \n",
"
\n",
" \n",
" 6 | \n",
" ./lib_src/length.c:47: | \n",
" 0.000013 | \n",
" 1 | \n",
" 0.000013 | \n",
"
\n",
" \n",
" 11 | \n",
" ./lib_src/prebuild_gwn.c:57: | \n",
" 0.000009 | \n",
" 1 | \n",
" 0.000009 | \n",
"
\n",
" \n",
" 0 | \n",
" ./lib_src/Py_getvalues.c:157: | \n",
" 0.000007 | \n",
" 1 | \n",
" 0.000007 | \n",
"
\n",
" \n",
" 13 | \n",
" ./lib_src/clean_real.c:48: | \n",
" 0.000007 | \n",
" 1 | \n",
" 0.000007 | \n",
"
\n",
" \n",
" 5 | \n",
" ./lib_src/maxfactor.c:42: | \n",
" 0.000004 | \n",
" 1 | \n",
" 0.000004 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" function_name elapsed_time executions total_time\n",
"15 ./lib_src/Py_kgeneration.c:74: 0.023829 1 0.023829\n",
"14 ./lib_src/fftma2.c:106: 0.012503 1 0.012503\n",
"9 ./lib_src/covariance.c:86: 0.012162 1 0.012162\n",
"4 ./lib_src/generate.c:75: 0.010957 1 0.010957\n",
"2 ./lib_src/gasdev.c:35: 0.000023 151 0.003473\n",
"8 ./lib_src/cov_value.c:60: 0.000011 76 0.000836\n",
"3 ./lib_src/gasdev.c:43: 0.000003 202 0.000606\n",
"1 ./lib_src/ran2.c:68: 0.000004 142 0.000568\n",
"10 ./lib_src/fourt.c:593: 0.000065 2 0.000130\n",
"7 ./lib_src/cgrid.c:50: 0.000060 1 0.000060\n",
"12 ./lib_src/build_real.c:50: 0.000019 1 0.000019\n",
"6 ./lib_src/length.c:47: 0.000013 1 0.000013\n",
"11 ./lib_src/prebuild_gwn.c:57: 0.000009 1 0.000009\n",
"0 ./lib_src/Py_getvalues.c:157: 0.000007 1 0.000007\n",
"13 ./lib_src/clean_real.c:48: 0.000007 1 0.000007\n",
"5 ./lib_src/maxfactor.c:42: 0.000004 1 0.000004"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.sort_values(by=[\"total_time\"], 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": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.9"
}
},
"nbformat": 4,
"nbformat_minor": 2
}