Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

MyCoolStory.cpp

Name: Anonymous 2011-04-06 9:56

>write awesome but buggy as hell C program to kick ass at minesweeper
>1 second top score on expert mode.  .47 seconds if I use a clone that keeps track of decimals.
>nagging feeling that I'm being a noob by writing in C and not C++
>learn C++ and rewrite program using classes and maps and vectors and lists and that kind of shit instead of just arrays.
>program works perfectly now, code is much cleaner, but it can't solve an expert board in under 10 seconds
>switch on every speed optimization I can find in Visual Studio
>times down to 6-7 seconds
>decide to rewrite the whole thing in C again from scratch so maybe it can be fast AND reliable at the same time
>change mind and decide to bitch to /prog/ instead and then take a nap

Name: Anonymous 2011-04-12 17:34

>>61
No, not cache misses per se. OP was using the wrong data structures. Instead of using 2-dimensional arrays with O(1) lookup complexity like he was in C, he thought it was a good idea to use std::map, which is usually a red-black tree or avl tree with O(log n) lookup complexity, simply because he wanted to ``make it look more like C++,'' whatever that means. He has since corrected his mistake. Yes, using std::map does stress the cache more by nature of nodes not being local to one another using the default allocator, as well as link and allocation overhead. However, using a std::map for something that can easily be implementing as a memory offset calculation for indexing into an array is the real meat of the problem.

In other words, >>62 is correct.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List