If you really care you should try and measure. However the most portable way is using std::fill():
std::fill( array, array + numberOfElements, 0.0 );
More Related Contents:
- Why does C++ code for testing the Collatz conjecture run faster than hand-written assembly?
- Modular arithmetics and NTT (finite field DFT) optimizations
- How to overload std::swap()
- Why is transposing a matrix of 512×512 much slower than transposing a matrix of 513×513?
- How to write a large buffer into a binary file in C++, fast?
- Is it better to use std::memcpy() or std::copy() in terms to performance?
- Virtual functions and performance – C++
- while (1) Vs. for (;;) Is there a speed difference?
- Optimizing member variable order in C++
- my first c++ program runtime is super long like 5 – 10 minutes on a fast CPU it's a very basic c++ program [closed]
- Which yields faster code?
- What exactly is the “as-if” rule?
- How to get the CPU cycle count in x86_64 from C++?
- Advantage of switch over if-else statement
- Why does C++ compilation take so long?
- Is the compiler allowed to optimize out heap memory allocations?
- What is more efficient? Using pow to square or just multiply it with itself?
- Efficient way of storing Huffman tree
- How do exceptions work (behind the scenes) in c++
- What is the real overhead of try/catch in C#?
- How can I know which parts in the code are never used?
- Does a C++11 range-based for loop condition get evaluated every cycle?
- linux perf: how to interpret and find hotspots
- Is RVO (Return Value Optimization) applicable for all objects?
- What is the Fastest Method for High Performance Sequential File I/O in C++?
- Is optimisation level -O3 dangerous in g++?
- Is std::vector memory freed upon a clear?
- Fastest way to get a positive modulo in C/C++
- Faster approach to checking for an all-zero buffer in C?
- Skip some arguments in a C++ function?