/mobile Handheld Friendly website

 performance measurements

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

 N  CPU secs Elapsed secs Memory KB Code B ≈ CPU Load
1064.1164.135,120536  1% 0% 0% 100%
11820.82820.985,120536  0% 0% 0% 100%
1210,672.1510,674.265,116536  0% 0% 0% 100%

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

Read fannkuch-redux benchmark to see what this program should do.

 notes

cint 5.18.00, July 2, 2010

Here CINT is only being used as a C interpreter but a CINT script can call compiled classes/functions and compiled code can make callbacks to CINT interpreted functions.

 fannkuch-redux C CINT program source code

/*
 * The Computer Language Benchmarks Game
 * http://benchmarksgame.alioth.debian.org/
 *
 * converted to C by Joseph Piché
 * from Java version by Oleg Mazurov and Isaac Gouy
 *
 * modified by Isaac Gouy for CINT
 *
 */

#include <stdio.h>
#include <stdlib.h>

inline static int max(int a, int b)
{
    return a > b ? a : b;
}

static int fannkuchredux(int n)
{
    int* perm;
    int* perm1;
    int* count;
    int maxFlipsCount = 0;
    int permCount = 0;
    int checksum = 0;

    int i;

    perm  = calloc(n, sizeof(*perm ));
    perm1 = calloc(n, sizeof(*perm1));
    count = calloc(n, sizeof(*count));

    for (i=0; i<n; i+=1)
        perm1[i] = i;
    int r = n;

    while (1) {
        while (r != 1) {
            count[r-1] = r;
            r -= 1;
        }

        for (i=0; i<n; i+=1)
            perm[i] = perm1[i];
        int flipsCount = 0;
        int k;

        while ( !((k = perm[0]) == 0) ) {
            int k2 = (k+1) >> 1;
            for (i=0; i<k2; i++) {
                int temp = perm[i]; perm[i] = perm[k-i]; perm[k-i] = temp;
            }
            flipsCount += 1;
        }

        maxFlipsCount = max(maxFlipsCount, flipsCount);
        checksum += permCount % 2 == 0 ? flipsCount : -flipsCount;

        /* Use incremental change to generate another permutation */
        while (1) {
            if (r == n) {
                printf("%d\n", checksum);
                return maxFlipsCount;
            }

            int perm0 = perm1[0];
            i = 0;
            while (i < r) {
                int j = i + 1;
                perm1[i] = perm1[j];
                i = j;
            }
            perm1[r] = perm0;
            count[r] = count[r] - 1;
            if (count[r] > 0) break;
            r++;
        }
        permCount++;
    }
}

int main(int argc, char ** argv)
{
    int n = atoi(argv[1]);
    printf("Pfannkuchen(%d) = %d\n", n, fannkuchredux(n));
    return 0;
}

 make, command-line, and program output logs

Thu, 21 Apr 2011 03:04:39 GMT

COMMAND LINE:
/usr/local/src/cint/bin/cint -K -p -E -E -J0  fannkuchredux.cint 12

PROGRAM OUTPUT:
3968050
Pfannkuchen(12) = 65

Revised BSD license

  Home   Conclusions   License   Play