A summary of the above program, since I don't know how to make it all one message:
1. Creates copies of a test program (a Mandelbrot).
2. Compiles each copy with a different optimization parameter.
3. Endless loop of running the copies, incrementing a counter for each winner, showing the timing and counters.
In 100 runs, -O2 won 44 times, -O3 37 times, and -Ofast 19.
I suppose the results will vary according to processor, O/S, and what test program is used.
1. Creates copies of a test program (a Mandelbrot).
2. Compiles each copy with a different optimization parameter.
3. Endless loop of running the copies, incrementing a counter for each winner, showing the timing and counters.
In 100 runs, -O2 won 44 times, -O3 37 times, and -Ofast 19.
I suppose the results will vary according to processor, O/S, and what test program is used.