/mobile Handheld Friendly website

 performance measurements

Each table row shows performance measurements for this C++ g++ program with a particular command-line input value N.

 N  CPU secs Elapsed secs Memory KB Code B ≈ CPU Load
1,0000.160.16?590  0% 0% 0% 100%
4,0002.392.392,924590  0% 0% 1% 100%
16,00037.7137.7232,232590  0% 1% 1% 100%

Read the ↓ make, command line, and program output logs to see how this program was run.

Read mandelbrot benchmark to see what this program should do.

 notes

gcc version 4.8.1 (Ubuntu/Linaro 4.8.1-10ubuntu8)

 mandelbrot C++ g++ #5 program source code

// The Computer Language Benchmarks Game

// http://benchmarksgame.alioth.debian.org/

//

// contributed by Elam Kolenovic

//

// Changes (2013-04-07):

//   - removed unnecessary arrays, faster especially on 32 bits

//   - using putchar instead of iostreams, slightly faster

//   - using namespace std for readability

//   - replaced size_t with unsigned

//   - removed some includes


#include <cstdio>

#include <cstdlib>

#include <limits>

#include <vector>


typedef unsigned char Byte;

using namespace std;

int main(int argc, char* argv[])
{
    const unsigned N             = max(0, (argc > 1) ? atoi(argv[1]) : 0);
    const unsigned width         = N;
    const unsigned height        = N;
    const unsigned maxX          = (width + 7) / 8;
    const unsigned maxIterations = 50;
    const double   limit         = 2.0;
    const double   limitSq       = limit * limit;

    vector<Byte> data(height * maxX);

    printf("P4\n%u %u\n", width, height);

    for (unsigned y = 0; y < height; ++y)
    {
        const double ci0 = 2.0 * y / height - 1.0;

        for (unsigned x = 0; x < maxX; ++x)
        {
            double cr0[8];
            for (unsigned k = 0; k < 8; ++k)
            {
                cr0[k] = 2.0 * (8 * x + k) / width - 1.5;
            }

            double cr[8];
            copy(cr0, cr0 + 8, &cr[0]);

            double ci[8];
            fill(ci, ci + 8, ci0);

            Byte bits = 0;
            for (unsigned i = 0; i < maxIterations && bits != 0xFF; ++i)
            {
                for (unsigned k = 0; k < 8; ++k)
                {
                    const Byte mask = (1 << (7 - k));
                    if ((bits & mask) == 0)
                    {
                        const double crk  = cr[k];
                        const double cik  = ci[k];
                        const double cr2k = crk * crk;
                        const double ci2k = cik * cik;

                        cr[k] = cr2k - ci2k + cr0[k];
                        ci[k] = 2.0 * crk * cik + ci0;

                        if (cr2k + ci2k > limitSq)
                        {
                            bits |= mask;
                        }
                    }
                }
            }
            putchar(~bits);
        }
    }

    return 0;
}

 make, command-line, and program output logs

Sun, 27 Oct 2013 01:00:51 GMT

MAKE:
/usr/bin/g++ -c -pipe -O3 -fomit-frame-pointer -march=native -mfpmath=sse -msse2 -fopenmp -mfpmath=sse -msse2 mandelbrot.gpp-5.c++ -o mandelbrot.gpp-5.c++.o &&  \
        /usr/bin/g++ mandelbrot.gpp-5.c++.o -o mandelbrot.gpp-5.gpp_run -fopenmp 
rm mandelbrot.gpp-5.c++
0.26s to complete and log all make actions

COMMAND LINE:
./mandelbrot.gpp-5.gpp_run 16000

(BINARY) PROGRAM OUTPUT NOT SHOWN

Revised BSD license

  Home   Conclusions   License   Play