Skip to content

Commit 1f93e68

Browse files
simplify file includes
1 parent 1b0124d commit 1f93e68

4 files changed

Lines changed: 90 additions & 25 deletions

File tree

scripts/deep_analysis_plotter.ipynb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,8 @@
3434
"outputs": [],
3535
"source": [
3636
"files = [\n",
37-
" 'a_inline_deep.json',\n",
38-
" 'b_inline_deep.json',\n",
39-
" 'a_pipeline_deep.json',\n",
40-
" 'b_pipeline_deep.json',\n",
37+
" 'a_deep_analysis.json',\n",
38+
" 'b_deep_analysis.json',\n",
4139
"]"
4240
]
4341
},

scripts/frame_breakdown_stackplot.ipynb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,8 @@
3434
"outputs": [],
3535
"source": [
3636
"files = [\n",
37-
" 'a_inline_deep.json',\n",
38-
" 'b_inline_deep.json',\n",
39-
" 'a_pipeline_deep.json',\n",
40-
" 'b_pipeline_deep.json',\n",
37+
" 'a_deep_analysis.json',\n",
38+
" 'b_deep_analysis.json',\n",
4139
"]"
4240
]
4341
},

scripts/per_frame_plotter.ipynb

Lines changed: 61 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
"id": "1d9d9451-25fe-40d7-a67e-2fcaf6a9f54a",
77
"metadata": {},
88
"outputs": [],
9-
"source": "# Install dependencies into the active kernel\n%pip install pandas matplotlib"
9+
"source": [
10+
"# Install dependencies into the active kernel\n",
11+
"%pip install pandas matplotlib"
12+
]
1013
},
1114
{
1215
"cell_type": "code",
@@ -29,10 +32,8 @@
2932
"outputs": [],
3033
"source": [
3134
"files = [\n",
32-
" 'a_inline_perframe.csv',\n",
33-
" 'a_pipeline_perframe.csv',\n",
34-
" 'b_inline_perframe.csv',\n",
35-
" 'b_pipeline_perframe.csv',\n",
35+
" 'a_deep_analysis.json',\n",
36+
" 'b_deep_analysis.json',\n",
3637
"]"
3738
]
3839
},
@@ -42,23 +43,74 @@
4243
"id": "a5f9ea81-7bd2-4f70-a0b8-45164afe8f76",
4344
"metadata": {},
4445
"outputs": [],
45-
"source": "scores = {}\nfor file in files:\n file_scores = pd.read_csv(file)\n # Drop all-zero (empty) columns\n file_scores = file_scores.loc[:, (file_scores != 0).any(axis=0)]\n scores[file] = file_scores\nscores = pd.concat(scores)\n\n# Frame time = delta between consecutive sequence timestamps\nscores['Frame time (ms)'] = (scores['Sequence Time (ns)'].shift(-1) - scores['Sequence Time (ns)']) / 1_000_000\n# The final frame's delta is negative (the benchmark loops) and the first 3 frames\n# are huge outliers, so drop both.\nscores['Frame time (ms)'] = scores['Frame time (ms)'].mask(\n (scores['Frame time (ms)'] < 0) | (scores['Frame'] < 3)\n)\n\n# Reshape into row per input file + sequence time, column per metric\nscores = scores.reset_index().set_index(['level_0', 'Sequence Time (ns)']).drop(['level_1', 'Loop Index', 'Frame'], axis=1)\n\n# Convert the nanosecond timing columns to milliseconds\nfor col in ['Ray Tracing', 'Acceleration Structure Build', 'Rasterization', 'Compute', 'Driver']:\n scores[f'{col} (ms)'] = scores.pop(f'{col} (ns)') / 1_000_000\nscores"
46+
"source": [
47+
"scores = {}\n",
48+
"for file in files:\n",
49+
" file_scores = pd.read_csv(file)\n",
50+
" # Drop all-zero (empty) columns\n",
51+
" file_scores = file_scores.loc[:, (file_scores != 0).any(axis=0)]\n",
52+
" scores[file] = file_scores\n",
53+
"scores = pd.concat(scores)\n",
54+
"\n",
55+
"# Frame time = delta between consecutive sequence timestamps\n",
56+
"scores['Frame time (ms)'] = (scores['Sequence Time (ns)'].shift(-1) - scores['Sequence Time (ns)']) / 1_000_000\n",
57+
"# The final frame's delta is negative (the benchmark loops) and the first 3 frames\n",
58+
"# are huge outliers, so drop both.\n",
59+
"scores['Frame time (ms)'] = scores['Frame time (ms)'].mask(\n",
60+
" (scores['Frame time (ms)'] < 0) | (scores['Frame'] < 3)\n",
61+
")\n",
62+
"\n",
63+
"# Reshape into row per input file + sequence time, column per metric\n",
64+
"scores = scores.reset_index().set_index(['level_0', 'Sequence Time (ns)']).drop(['level_1', 'Loop Index', 'Frame'], axis=1)\n",
65+
"\n",
66+
"# Convert the nanosecond timing columns to milliseconds\n",
67+
"for col in ['Ray Tracing', 'Acceleration Structure Build', 'Rasterization', 'Compute', 'Driver']:\n",
68+
" scores[f'{col} (ms)'] = scores.pop(f'{col} (ns)') / 1_000_000\n",
69+
"scores"
70+
]
4671
},
4772
{
4873
"cell_type": "code",
4974
"execution_count": null,
5075
"id": "b4bbc8ad-fbf4-4c96-8aa4-afb02ff305a0",
5176
"metadata": {},
5277
"outputs": [],
53-
"source": "# Reshape into row per sequence time + metric, column per input file\nnew_scores = scores.stack().unstack(0).reset_index()\nnew_scores.columns.name = None # drop the leftover index name so it isn't a \"level_0\" legend title\n\n# ns to s for the sequence time\nnew_scores['Sequence Time (s)'] = new_scores['Sequence Time (ns)'] / 1_000_000_000\nnew_scores = new_scores.drop('Sequence Time (ns)', axis=1)\nnew_scores"
78+
"source": [
79+
"# Reshape into row per sequence time + metric, column per input file\n",
80+
"new_scores = scores.stack().unstack(0).reset_index()\n",
81+
"new_scores.columns.name = None # drop the leftover index name so it isn't a \"level_0\" legend title\n",
82+
"\n",
83+
"# ns to s for the sequence time\n",
84+
"new_scores['Sequence Time (s)'] = new_scores['Sequence Time (ns)'] / 1_000_000_000\n",
85+
"new_scores = new_scores.drop('Sequence Time (ns)', axis=1)\n",
86+
"new_scores"
87+
]
5488
},
5589
{
5690
"cell_type": "code",
5791
"execution_count": null,
5892
"id": "2d6b6f75-251b-4bb2-aa44-e6393cf8140a",
5993
"metadata": {},
6094
"outputs": [],
61-
"source": "pathlib.Path('output_per_frame').mkdir(parents=True, exist_ok=True)\nfor graph_name in new_scores['level_1'].unique():\n graph_data = new_scores[new_scores['level_1'] == graph_name].drop('level_1', axis=1)\n graph_data = graph_data.apply(pd.to_numeric, errors='coerce').interpolate(method='linear')\n\n ax = graph_data.plot(\n x='Sequence Time (s)',\n xlabel='benchmark timeline in seconds',\n ylabel='value',\n title=graph_name,\n figsize=(20, 5),\n colormap='Dark2',\n grid=True,\n rot=0,\n )\n ax.figure.savefig(f'output_per_frame/{graph_name}.png')\n plt.close(ax.figure) # free the figure so we don't keep one open per metric\n"
95+
"source": [
96+
"pathlib.Path('output_per_frame').mkdir(parents=True, exist_ok=True)\n",
97+
"for graph_name in new_scores['level_1'].unique():\n",
98+
" graph_data = new_scores[new_scores['level_1'] == graph_name].drop('level_1', axis=1)\n",
99+
" graph_data = graph_data.apply(pd.to_numeric, errors='coerce').interpolate(method='linear')\n",
100+
"\n",
101+
" ax = graph_data.plot(\n",
102+
" x='Sequence Time (s)',\n",
103+
" xlabel='benchmark timeline in seconds',\n",
104+
" ylabel='value',\n",
105+
" title=graph_name,\n",
106+
" figsize=(20, 5),\n",
107+
" colormap='Dark2',\n",
108+
" grid=True,\n",
109+
" rot=0,\n",
110+
" )\n",
111+
" ax.figure.savefig(f'output_per_frame/{graph_name}.png')\n",
112+
" plt.close(ax.figure) # free the figure so we don't keep one open per metric\n"
113+
]
62114
}
63115
],
64116
"metadata": {
@@ -82,4 +134,4 @@
82134
},
83135
"nbformat": 4,
84136
"nbformat_minor": 5
85-
}
137+
}

scripts/scores_plotter.ipynb

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,22 @@
66
"id": "c7a3c3bd-54d5-4979-8502-ac69a32a13fb",
77
"metadata": {},
88
"outputs": [],
9-
"source": "# Install dependencies into the active kernel\n%pip install pandas matplotlib"
9+
"source": [
10+
"# Install dependencies into the active kernel\n",
11+
"%pip install pandas matplotlib"
12+
]
1013
},
1114
{
1215
"cell_type": "code",
1316
"execution_count": null,
1417
"id": "21658370-184d-4ab0-b210-d8ab93f0818b",
1518
"metadata": {},
1619
"outputs": [],
17-
"source": "import pandas as pd\nimport os\nimport matplotlib.pyplot as plt"
20+
"source": [
21+
"import pandas as pd\n",
22+
"import os\n",
23+
"import matplotlib.pyplot as plt"
24+
]
1825
},
1926
{
2027
"cell_type": "code",
@@ -24,10 +31,8 @@
2431
"outputs": [],
2532
"source": [
2633
"files = [\n",
27-
" 'scores/5070ti_inline.csv',\n",
28-
" 'scores/5070ti_pipeline.csv',\n",
29-
" 'scores/9070xt_inline.csv',\n",
30-
" 'scores/9070xt_pipeline.csv',\n",
34+
" 'a_deep_analysis.json',\n",
35+
" 'b_deep_analysis.json',\n",
3136
"]"
3237
]
3338
},
@@ -59,7 +64,19 @@
5964
"id": "d89bab16-7553-4fd2-953b-05a054362999",
6065
"metadata": {},
6166
"outputs": [],
62-
"source": "os.makedirs('output_scores', exist_ok=True)\nax = scores.plot(\n kind=\"bar\",\n figsize=(20, 5),\n colormap='Dark2',\n grid=True,\n rot=0,\n title=\"Evolve scores (higher is better)\",\n ylabel=\"score\",\n)\nax.figure.savefig('output_scores/evolve_scores.png', bbox_inches='tight')"
67+
"source": [
68+
"os.makedirs('output_scores', exist_ok=True)\n",
69+
"ax = scores.plot(\n",
70+
" kind=\"bar\",\n",
71+
" figsize=(20, 5),\n",
72+
" colormap='Dark2',\n",
73+
" grid=True,\n",
74+
" rot=0,\n",
75+
" title=\"Evolve scores (higher is better)\",\n",
76+
" ylabel=\"score\",\n",
77+
")\n",
78+
"ax.figure.savefig('output_scores/evolve_scores.png', bbox_inches='tight')"
79+
]
6380
}
6481
],
6582
"metadata": {
@@ -83,4 +100,4 @@
83100
},
84101
"nbformat": 4,
85102
"nbformat_minor": 5
86-
}
103+
}

0 commit comments

Comments
 (0)