Time my code

Published: 09/02/2025

Some numbers of timing the update_fractal() function to be fully executed.

Time my code

I timed my update_fractal() function for different scenarios in the final code using the time module from python.

What? I only changed the max_levels, nothing else has changed yet.
Amount times executed? 3 times
This is the average time per level that the update_fractal() takes to execute:

max_levelaverage (in seconds)
00.0055 sec
10.0154 sec
20.1101 sec


What? I change the rotation for the 3 axes, then I change the max_level:
Amount times executed? 3 times
Results - time it takes update_fractal() to execute:

max_levelfirst timesecond timethird time
00.0080 sec0.0085 sec0.0099 sec
10.0177 sec0.0198 sec0.0232 sec
20.1376 sec0.1372 sec0.1461 sec


What? I empty the canvas and I change my desired level and then change all properties.

max_levelamount times update_fractal executedmin. valuemax. valueaverage
0540.0010 sec0.0108 sec0.0018 sec
1690.0065 sec0.0319 sec0.0096 sec
2420.0816 sec0.5206 sec0.3599 sec


Conclusion: I find that with max_level = 2, things are a lot harder when I want to change things quickly. It’s just about right. So you have to be a bit careful to adjust things, a bit more patient to adjust things.

What? I also timed the time to calculate everything in my refactored matplotlib project (without interactions).
Amount times executed? 6 times
Result:

projectaverage
without NumPy0.1591 sec
with NumPy0.0914 sec


Conclusion: when refactored with NumPy, the code is faster than without NumPy. NumPy then also makes for faster calculations because it uses N-dimensional arrays and no python list to go over.