[Issue 5650] A RedBlackTree performance problem

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Feb 24 14:30:19 PST 2011


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



--- Comment #3 from bearophile_hugs at eml.cc 2011-02-24 14:27:34 PST ---
The D version runs in about 20.6 seconds, the Java -server version in about
0.49 seconds, and this C++ (GCC 4.5.1 -O3) version in about 0.3 seconds (this
is not a fully apples-to-apples comparison because this doesn't use a GC, but
it's good as reference point):


#include <stdio.h>
#include <set>

using namespace std;

int main() {
    const int range = 100;
    const int n = 1000000;

    set<int> t;
    for (int i = 0; i < n; i++) {
        if (i > range)
            t.erase(t.begin());
        t.insert(i);
    }

    printf("%d\n", t.size());
    //for (set<int>::iterator it=t.begin(); it!=t.end(); ++it)
    //    printf("%d ", *it);
    //printf("\n");

    return 0;
}

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


More information about the Digitalmars-d-bugs mailing list