2 ms·
Code is not the only element in the process generating GHG. The coder's way of life, the coder's tool, the resources needed should all be taken into account. Wh
by marsokod 6y ago
Code is not the only element in the process generating GHG. The coder's way of life, the coder's tool, the resources needed should all be taken into account. What matters in the end is the global footprint of the code.
Writing quickly a very inefficient code that will run a handful of time is much better than spending 2 months full time optimizing it. And straightforward codes are also easier to debug. It may be a concept quite linked to Python, be premature optimization is where the crux of the problem is. Except we are now talking about an optimisation in processing power with an impact that is much wider, and thus with a more complex link.
- bluGill 6y agoIn the case of C++ it is often noted by library writers that simple implementations often beat their most complex efforts in the real world: between the compiler optimizing better, and simple algorithms leading to less CPU stalls because of a cache miss In the real world O(n) is faster than O(log n) on all real data. (that is data that fits in RAM)
- quicknir 6y agoI would encourage you to benchmark linear search and binary search on a dynamic array (std::vector) of a million elements. You may be in for a surprise. I can only assume you have 4KB of ram.