C++ 28 May 2011 19:04:13

C++ Convert String to Double Speed

(There is also a string-to-int performance test.)

A performance benchmark of which method is faster of converting an std::string to a double. The goal is ending up with a double of the value represented in an std::string.

The tested methods are:

Source for the test is at speed-string-to-double.cpp with cycle.h.

The compilers are Microsoft Visual C++ 2010 with _SECURE_SCL disabled, GNU g++ 4.6.0, and LLVM clang++ from Arch.


Continue Reading »

Random 18 May 2011 21:32:04

BrainHex Class

Your BrainHex Class
Your BrainHex Class is Mastermind.

Your BrainHex Sub-Class is MastermindSeeker.

You like solving puzzles and devising strategies as well as finding strange and wonderful things or finding familiar things.

Each BrainHex Class also has an Exception, which describes what you dislike about playing games. Your Exceptions are:

» No Fear: You do not enjoy feeling afraid, preferring to feel safe or in control.

Your scores for each of the classes in this test were as follows:

Mastermind: 20
Seeker: 17
Achiever: 13
Socialiser: 7
Daredevil: 4
Conqueror: 2
Survivor: -2

C++ 10 Feb 2011 18:24:56

C++ String Compare Performance

A performance comparison of the speed of various ways to compare strings in C++. In this test, all comparisons are of not-equal strings.

Idea from #C++ on QuakeNet, where we always advocate using std::string over various char* functions. I wondered what, if any, the penalty for doing so was.

Sources

Things Tested

  • a hand-written naive comparator loop; used as baseline
  • string == string
  • string == const char*
  • strcmp(const char*, const char*) == 0
  • strcmp(const char*, string.c_str()) == 0
  • strcmp(string.c_str(), string.c_str()) == 0
  • string.compare(string)
  • string.compare(const char*)
  • …and then the whole thing with different offsets.


Continue Reading »

C++ 28 Jan 2011 16:21:01

C++ Read Whole File Performance

A performance comparison of the speed of various ways to read an entire file into an std::string in C++.

Idea from BD-Calvin in #C++ on QuakeNet.

Sources

Things Tested

  • writing to a stringstream, then pulling data out as string
  • constructing a string via streambuf_iterator
  • getting file size via seeking, then preallocating a string to read into
  • getting file size via stat(), then ditto…


Continue Reading »

Reviews 02 Jan 2011 02:14:51

BioShock

BioShock for PC from Steam.

In a word: Underwhelming.

I expected so much more from this game, and it failed in every way. Weapons are boring, plasmids are bland and don’t feel very powerful, enemies are annoying and get really old really fast, scripted events are predictable, story totally failed to capture me, and the environment is almost exactly opposite of what I want.

I got all that from the 1.5 hours I spent playing it. And then I watched the Spoiler Warning play-through of it which confirmed my assumptions; it is simply not a game I would ever enjoy. Maybe if they juiced up the plasmids a lot and let the “mana” regenerate on its own…

« Previous PageNext Page »