I have the following C++ program:
Qt Code:
  1. #include <map>
  2. #include <string>
  3. #include <QDebug>
  4. #include <QMap>
  5. #include <QElapsedTimer>
  6.  
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11. QElapsedTimer t;
  12.  
  13. qint64 e;
  14. const int COUNT = 1000000;
  15.  
  16. // using std::map
  17. t.start();
  18. map<int,string> m;
  19. for(int i = 0; i < COUNT; i++)
  20. m[i] = "HI";
  21.  
  22. e = t.elapsed();
  23. qDebug() << e;
  24.  
  25. // using Map
  26. t.restart();
  27. QMap<int,string> m2;
  28. for(int i = 0; i < COUNT; i++)
  29. m2[i] = "HI";
  30. e = t.elapsed();
  31. qDebug() << e;
  32.  
  33. return 0;
  34. }
To copy to clipboard, switch view to plain text mode 
Compiled in release mode, the std::map version gives me a result of 208 ms, while the QMap version gives me a result of 220 ms.
But the .Net version is much faster
Qt Code:
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. internal class Program
  5. {
  6. private static void Main()
  7. {
  8. Stopwatch w = Stopwatch.StartNew();
  9. Dictionary<int, string> dic = new Dictionary<int, string>();
  10. long e;
  11. const int COUNT = 1000000;
  12.  
  13. for (int i = 0; i < COUNT; i++)
  14. {
  15. dic[i] = "HI";
  16. }
  17. w.Stop();
  18. e = w.ElapsedMilliseconds;
  19. Console.WriteLine(e);
  20. }
  21. }
To copy to clipboard, switch view to plain text mode 
This gives me a result of 60 ms!
Am I doing something wrong? Or the result is actually normal?