http://d.puremagic.com/issues/show_bug.cgi?id=4952



--- Comment #1 from bearophile_h...@eml.cc 2010-09-28 18:32:31 PDT ---
Some simple benchmark code, for comparison:

Timings, NLOOPS = 100_000, best of 6, seconds:
  DMD: 7.70
  GCC: 2.42

gcc  4.5.1, -Wall -O3 -s
dmd 2.049, -O -release -inline


// D code
import std.c.stdio: printf;

enum int NLOOPS = 100000;

int c1, c2, c3;

void f1() { c1++; }
void f2() { c2++; }
void f3() { c3++; }

int main() {
    int i, j;
    for (i = 0; i < NLOOPS; i++) {
        for (j = 0; j < 5000; j++) {
            switch (j) {
                case 140: f1(); break;
                case 300: f1(); break;
                case 1280: f1(); break;
                case 1540: f1(); break;
                case 1660: f1(); break;
                case 1770: f2(); break;
                case 2150: f2(); break;
                case 2190: f1(); break;
                case 2530: f2(); break;
                case 2560: f2(); break;
                case 2590: f1(); break;
                case 2660: f1(); break;
                case 2720: f2(); break;
                case 3010: f1(); break;
                case 3100: f1(); break;
                case 3390: f2(); break;
                case 3760: f1(); break;
                case 3970: f2(); break;
                case 4050: f1(); break;
                case 4140: f1(); break;
                case 4360: f2(); break;
                case 4540: f1(); break;
                case 4600: f2(); break;
                case 4720: f2(); break;
                case 4730: f2(); break;
                case 4740: f2(); break;
                case 4880: f2(); break;
                case 4950: f1(); break;

                default: f3();
            }
        }
    }

    printf("%d %d %d\n", c1, c2, c3);
    return 0;
}



// C code
#include "stdio.h"

#define NLOOPS 100000

int c1, c2, c3;

void f1() { c1++; }
void f2() { c2++; }
void f3() { c3++; }

int main() {
    int i, j;
    for (i = 0; i < NLOOPS; i++) {
        for (j = 0; j < 5000; j++) {
            switch (j) {
                case 140: f1(); break;
                case 300: f1(); break;
                case 1280: f1(); break;
                case 1540: f1(); break;
                case 1660: f1(); break;
                case 1770: f2(); break;
                case 2150: f2(); break;
                case 2190: f1(); break;
                case 2530: f2(); break;
                case 2560: f2(); break;
                case 2590: f1(); break;
                case 2660: f1(); break;
                case 2720: f2(); break;
                case 3010: f1(); break;
                case 3100: f1(); break;
                case 3390: f2(); break;
                case 3760: f1(); break;
                case 3970: f2(); break;
                case 4050: f1(); break;
                case 4140: f1(); break;
                case 4360: f2(); break;
                case 4540: f1(); break;
                case 4600: f2(); break;
                case 4720: f2(); break;
                case 4730: f2(); break;
                case 4740: f2(); break;
                case 4880: f2(); break;
                case 4950: f1(); break;

                default: f3();
            }
        }
    }

    printf("%d %d %d\n", c1, c2, c3);
    return 0;
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to