Profiling #293
Replies: 3 comments 4 replies
-
Here are results of profiling using a modified version the included profiling script. The script used here is below. sample_inputs = SampleInputs()
sample_inputs.floris["wake"]["model_strings"]["velocity_model"] = "gauss"
sample_inputs.floris["wake"]["model_strings"]["deflection_model"] = "gauss"
sample_inputs.floris["wake"]["enable_secondary_steering"] = True
sample_inputs.floris["wake"]["enable_yaw_added_recovery"] = True
sample_inputs.floris["wake"]["enable_transverse_velocities"] = True
factor = 100
TURBINE_DIAMETER = sample_inputs.floris["farm"]["turbine_type"][0]["rotor_diameter"]
sample_inputs.floris["farm"]["layout_x"] = [5 * TURBINE_DIAMETER * i for i in range(factor)]
sample_inputs.floris["farm"]["layout_y"] = [0.0 for i in range(factor)]
factor = 10
sample_inputs.floris["flow_field"]["wind_directions"] = factor * [270.0]
sample_inputs.floris["flow_field"]["wind_speeds"] = factor * [8.0]
floris = Floris.from_dict(sample_inputs.floris)
floris.initialize_domain()
floris.steady_state_atmospheric_condition() First, I compared the three high-level functions required to initialize and run the simulation. As expected, the calculation step is the most expensive.
Next, I profiled the
The largest expense here is
|
Beta Was this translation helpful? Give feedback.
-
This is really interesting to see @rafmudaf ! Do you think you could generate similar timing plots with GCH turned off as well? Just wondering if there will be any significant changes in the other calls of the code. There shouldn't be, but curious to see if there is some other impact from memory or something else. |
Beta Was this translation helpful? Give feedback.
-
Here's the timing of the sequential solve function with GCH off. The script is below and then the timing. sample_inputs = SampleInputs()
sample_inputs.floris["wake"]["model_strings"]["velocity_model"] = "gauss"
sample_inputs.floris["wake"]["model_strings"]["deflection_model"] = "gauss"
sample_inputs.floris["wake"]["enable_secondary_steering"] = False
sample_inputs.floris["wake"]["enable_yaw_added_recovery"] = False
sample_inputs.floris["wake"]["enable_transverse_velocities"] = False
factor = 100
TURBINE_DIAMETER = sample_inputs.floris["farm"]["turbine_type"][0]["rotor_diameter"]
sample_inputs.floris["farm"]["layout_x"] = [5 * TURBINE_DIAMETER * i for i in range(factor)]
sample_inputs.floris["farm"]["layout_y"] = [0.0 for i in range(factor)]
factor = 10
sample_inputs.floris["flow_field"]["wind_directions"] = factor * [270.0]
sample_inputs.floris["flow_field"]["wind_speeds"] = factor * [8.0]
floris = Floris.from_dict(sample_inputs.floris)
floris.initialize_domain()
floris.steady_state_atmospheric_condition()
|
Beta Was this translation helpful? Give feedback.
-
Speed / Time
I've used cProfile in the past, but I found line_profiler to be much more user friendly. It handles pretty much everything for you and only requires adding a
@profile
decorator to the function to target.The package is called
line_profiler
but the executable iskernprof
, and it is run with this command:Another potentially relevant tool for profiling is scalene - a CPU, GPU and memory profiler.
Memory
Memory profiling has proved to be much more difficult. I've used memory_profiler due to its similar API to
line_profiler
- you simply add the same@profile
decorator to a function. However, the same code differs in memory measurement from run to run, so getting accurate results seems elusive.This package is run with:
Beta Was this translation helpful? Give feedback.
All reactions