Squeezing performance out of memcmp usage

When I wrote this the other day it made me think of another thing involving the memcmp function and the VC compiler. In the code I’ve seen over the years where memcmp was used it was always to find out if an area was identical or not. So the code typically looked something like this: 1:…

1

Exceptions or not?

I’ve always had mixed feelings for exceptions. First of all exceptions should only be used for exceptional things, not things that are expected. For example if you open a file it may fail for several reasons; it does not exists, you do not have rights to open it or it may be locked. These are…

0

Remember to allocate memory just in case you run out of memory

Today I read this blog post about how all .Net applications create three exceptions upon start; System.ExecutionEngineException, System.StackOverflowException and System.OutOfMemoryException. The reason is that if these are not allocated from the start, they cannot be created when they occur. This reminded me of when I was writing high performance daemons in C a few years…

0

A reminder if you want to read/write your file in non blocking mode (in C(++))

Sometimes you might want to read a file non-blocking. It could be /dev/random because waiting for entropy might take very long. Also when you have to read device files on unix you sometimes have to read them non-blocking. A common pattern is to open the file non-blocking using the open method: open(…, O_NONBLOCK, …) This…

0

Dangers of using Visual Studio 2008 Team System Code Coverage Tool for Native C++

So now you know how to get coverage reports for native C++ using Visual Studio 2008 Team System (if not – read this). There are a few things you need to know before you get excited. First of all the only metrics you get are line and block coverage. A block is basically a statement…

2

Native C++ Code Coverage reports using Visual Studio 2008 Team System

The code coverage tool in Visual Studio 2008 Team System is quite easy to use from within the IDE unless you want code coverage for your native C++ code. In order to generate a code coverage report for native C++ you have to use the command line tools. This is how you do it: First…

17

C++ pointer basics for kids

A little video to explain pointer basics in C++ to your kids… If you for some weird reason want to do that…

3

Sleep does not sleep for a specified period

I recently described how you can create your own usleep method when there isn’t one to use. one thing that people however tend to forget is that the sleep methods (sleep, usleep, nanosleep) only guarantees that the calling thread will be suspended for at least the given time. There is absolutely no guarantee that the…

0

Sleep less than one millisecond

On windows you have a problem you typically never encounter on Unix. That is how to get a thread to sleep for less than one millisecond. On Unix you typically have a number of choices (sleep, usleep and nanosleep) to fit your needs. On windows however there is only Sleep with millisecond granularity. You can…

1

Mocks are not Stubs

As many before me I was recently looking at different mocking frameworks in order to find one that suited my needs, and was written in C++. And there are not many alternatives out there if you’re using C++. I’ve found one open source and two internal (Microsoft staff can access what can be described as…

2