Page Menu
Home
Search
Configure Global Search
Log In
Paste
P2283
blender_test_perf.py
Active
Public
Actions
Authored by
Campbell Barton (campbellbarton)
on Jul 26 2021, 6:02 AM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Tags
None
Subscribers
None
#!/usr/bin/env python3
# NOTE: this relies on there being a timer in the normal function, example patch.
'''
diff --git a/source/blender/blenkernel/intern/mesh_normals.cc b/source/blender/blenkernel/intern/mesh_normals.cc
index f496d6eada1..bda094d504a 100644
--- a/source/blender/blenkernel/intern/mesh_normals.cc
+++ b/source/blender/blenkernel/intern/mesh_normals.cc
@@ -52,10 +52,10 @@
// #define DEBUG_TIME
-#ifdef DEBUG_TIME
-# include "PIL_time.h"
-# include "PIL_time_utildefines.h"
-#endif
+// #ifdef DEBUG_TIME
+#include "PIL_time.h"
+#include "PIL_time_utildefines.h"
+// #endif
static CLG_LogRef LOG = {"bke.mesh_normals"};
@@ -308,6 +308,7 @@ void BKE_mesh_calc_normals_poly(MVert *mverts,
float (*r_polynors)[3],
const bool only_face_normals)
{
+ TIMEIT_START(BKE_mesh_calc_normals_poly);
float(*pnors)[3] = r_polynors;
TaskParallelSettings settings;
@@ -368,6 +369,8 @@ void BKE_mesh_calc_normals_poly(MVert *mverts,
MEM_freeN(vnors);
}
MEM_freeN(lnors_weighted);
+
+ TIMEIT_END(BKE_mesh_calc_normals_poly);
}
void BKE_mesh_ensure_normals(Mesh *mesh)
'''
import
os
import
subprocess
TEST_FILES
=
"/test/files/normals"
files
=
(
# "regular_normals_00001k.blend",
# "regular_normals_00002k.blend",
# "regular_normals_00004k.blend",
# "regular_normals_00008k.blend",
# "regular_normals_00016k.blend",
# "regular_normals_00032k.blend",
"regular_normals_00064k.blend"
,
"regular_normals_00128k.blend"
,
"regular_normals_00256k.blend"
,
"regular_normals_00512k.blend"
,
"regular_normals_01024k.blend"
,
"regular_normals_02048k.blend"
,
"regular_normals_25000k.blend"
,
)
bins
=
(
"/src/release_build/bin/blender_before"
,
"/src/release_build/bin/blender"
,
)
time_data_per_file
=
[]
for
f
in
files
:
print
(
"
\n
===="
,
f
)
fp
=
os
.
path
.
join
(
TEST_FILES
,
f
)
time_for_each_binary
=
[]
for
bin
in
bins
:
print
(
"
\n
----"
,
bin
)
args
=
(
bin
,
"--factory-startup"
,
fp
,
"--enable-event-simulate"
,
"--python"
,
"/src/blender/tests/python/bl_run_operators_event_simulate.py"
,
"--"
,
"--time-actions"
,
"--actions"
,
'area_maximize(ui_type="VIEW_3D")'
,
'operator("transform.translate")'
,
'cursor_motion(path="CIRCLE", radius=300, steps=20, repeat=1)'
,
)
# print(args)
text
=
subprocess
.
check_output
(
args
)
.
decode
(
"utf-8"
)
text
=
text
.
split
(
"Read blend:"
,
1
)[
1
]
text
=
text
.
split
(
"Average:"
)[
0
]
print
(
text
)
t
=
0.0
n
=
0
for
l
in
text
.
split
(
"
\n
"
):
if
l
.
startswith
(
"time end "
):
t
+=
float
(
l
.
split
()[
3
])
n
+=
1
t
=
t
/
n
time_for_each_binary
.
append
(
t
)
time_data_per_file
.
append
((
f
,
tuple
(
time_for_each_binary
)))
print
(
"| File | Before | After | Speedup |"
)
speedup
=
0
speedup_count
=
0
for
f
,
(
t_before
,
t_after
)
in
time_data_per_file
:
print
(
"|
%s
|
%.6f
|
%.6f
|
%.6f
|"
%
(
f
,
t_before
,
t_after
,
t_before
/
t_after
))
speedup
+=
t_before
/
t_after
speedup_count
+=
1
print
(
"| | | |
%.6f
|"
%
(
speedup
/
speedup_count
))
# ----
# Snippet for matplotlib:
'''
import matplotlib.pyplot as plt
import matplotlib.ticker as ticker
# Data for plotting
fig, ax = plt.subplots()
ax.plot([d[0] for d in data], [d[1] for d in data])
ax.plot([d[0] for d in data], [d[2] for d in data])
print([d[0] for d in data])
ax.yaxis.set_major_formatter(ticker.FormatStrFormatter('%.4f sec'))
ax.xaxis.set_major_formatter(ticker.FormatStrFormatter('%.1f'))
ax.set(xlabel='Polygons (10k .. 2million)', ylabel='Time (seconds)',
title='Blue (before the patch), Orange (after)')
ax.grid()
fig.savefig("test.png")
plt.show()
'''
Event Timeline
Campbell Barton (campbellbarton)
created this paste.
Jul 26 2021, 6:02 AM
Campbell Barton (campbellbarton)
mentioned this in
D11993: Mesh: optimize normal calculation
.
Campbell Barton (campbellbarton)
edited the content of this paste.
(Show Details)
Jul 26 2021, 1:25 PM
Campbell Barton (campbellbarton)
edited the content of this paste.
(Show Details)
Campbell Barton (campbellbarton)
edited the content of this paste.
(Show Details)
Jul 26 2021, 1:29 PM
Campbell Barton (campbellbarton)
edited the content of this paste.
(Show Details)
Jul 26 2021, 1:31 PM
Campbell Barton (campbellbarton)
edited the content of this paste.
(Show Details)
Campbell Barton (campbellbarton)
edited the content of this paste.
(Show Details)
Jul 27 2021, 8:40 AM
Log In to Comment