removed1's blog

By removed1, 12 years ago, translation, In English

Continuing this thread (in Russian)

[disclaimer: these measurements are not accurate, they are like measuring RPM of engine during idle run, instead of time of racing car on track.., were not statistically tested, etc.]

I took maslowmw's code, changed size to 500, removed time printing (which doesn't make big difference) and tried it in Topcoder Practice Rooms. Indeed, 2d array in .NET version used at Topcoder, is slower than array-of-array (I think it should change in future, if not already: latest MS.NET version is 4.0). I got interested and tried several other variants. Here are the results, and make conclusions yourselves.

[i][j]: 1.328s
[i,j]: 1.516s
[i*size+j]: 0.875s

int [][]: 0.266s
int **: 0.791s
[i*size+j]: 0.286s % where size = const int
[i*size+j]: 0.695s % where size = input parameter
vector<vector<int>> : 0.478s % where size = const int
vector<vector<int>> : 0.608s % where size = input parameter

[i][j]: 1.927s
[i*size+j]: 1.306s

P.S.? After I clicked 'Know English' link to translate my post into English, the website removed my original tags and replaced them with "c++", "c#", "best language". WHO WROTE THIS CODE, AND WHY? Puzzle.

  • Vote: I like it
  • 0
  • Vote: I do not like it