Hi,
I'm comparing the following code in C++ and C# and C# (Mono 2.4) seems to be faster. Is there anything wrong with the C++ code?
#include <map>
#include <string>
#include <iostream>
#include <ext/hash_map>
#include <boost/any.hpp>
int main()
{
//std::map<long, long> m;
// hash_map is a little bit faster
__gnu_cxx::hash_map<long, long> m;
for( long i = 0; i < 1000000; ++i )
{
m[i] = i;
}
}
And C#
using System;
using System.Collections;
public int Main()
{
Hashtable m = new Hashtable();
for( long i = 0; i < 1000000; ++i )
{
m[i] = i;
}
}
C# code is actually twice as fast on the same machine.
$ time ./a.out
real 0m1.028s
user 0m0.986s
sys 0m0.041s
$ time mono test.exe
real 0m0.603s
user 0m0.732s
sys 0m0.090s