eighthill / Slime_Mold_Simulation

A student project simulating smile mold🧫
MIT License
6 stars 0 forks source link

runtime analysis #68

Closed Isabelle-Gbl closed 7 months ago

Isabelle-Gbl commented 7 months ago

compare runtime of code with and without numba and to earlier version of code How did we safe time by avoiding for loops and changing the agent class?

Isabelle-Gbl commented 7 months ago

already started with first version. will update informations as soon as main branch is up to date.

Isabelle-Gbl commented 7 months ago

This analysis compares the runtime complexities of Version 0 from January 2024 and the Final Version from February 2024. In Version 0, the initialization of Agent and Pheromone objects involves loops dependent on AGENT_NUMBER, resulting in linear runtime complexity (O(AGENT_NUMBER)). Conversely, the Final Version simplifies the structure, achieving constant runtime complexity (O(1)) for both initialization and the Main function.

The comparison demonstrates that the Final Version maintains consistent performance regardless of AGENT_NUMBER, while Version 0 exhibits linear runtime increase with AGENT_NUMBER growth. Consequently, the Final Version outperforms Version 0 in efficiency and scalability, offering stable and predictable runtime performance.

By measuring runtime for 100 Agents and a 100x100 pheromone array, Version 0 and the Final Version exhibit comparable performance, with the Final Version slightly faster. However, the NUMBA-Optimized Version shows slower runtimes. This shows that with a small number of agents, the compiling of code is not necessary or even increases the runtie.

For input with a 100x100 pheromone array and 100,000 agents, the Final Version exhibits superior performance compared to Version 0, showcasing significantly reduced runtimes for both average and total execution times. While the NUMBA-optimized version displays enhancements over Version 0, it still lags behind the Final Version's performance across the 10 loops. It's notable that the measured time for each loop indicates a substantial initial overhead during the first loop as functions are compiled in the NUMBA-optimized code. However, subsequent loops consistently demonstrate the NUMBA-optimized code's superiority over the uncompiled version.

In conclusion, the Final Version and the Final Version that is NUMBA-optimized consistently outperform Version 0 in terms of runtime performance, indicating the effectiveness of its design and implementation.

I'll later add the slide of our presentation about this to this Issue and in the documentary