Preprocessing Phase for C++17's Searchers

Searchers from C++17 are a new way to perform efficient pattern lookups. The new standard offers three searchers: default_searcher , boyer_moore_searcher and boyer_moore_horspool_searcher. The last two implements algorithms that require some additional preprocessing for the input pattern. Is there a chance to separate preprocessing time from the search time?

READ MORE...

How to Initialize a String Member

How do you initialise a string member in the constructor? By using const string&, string value and move, string_view or maybe something else? Let’s have a look at possible options. Intro Below there’s a simple class with one string member. We’d like to initialise it. For example: class UserName { std::string mName; public: UserName(const std::string& str) : mName(str) { } }; As you can see a constructor is taking const std::string& str.

READ MORE...

Performance of std::string_view vs std::string from C++17

How much is std::string_view faster than standard std::string operations? Have a look at a few examples where I compare std::string_view against std::string. Intro I was looking for some examples of string_view, and after a while, I got curious about the performance gain we might get. string_view is conceptually only a view of the string: usually implemented as[ptr, length].

READ MORE...

Please stop with performance optimizations!

As you might notice from reading this blog, I love doing performance optimizations. Let’s take some algorithm or some part of the app, understand it and then improve, so it works 5x… or 100x faster! Doesn’t that sound awesome? I hope that you answered “Yes” to the question in the introduction.

READ MORE...

Curious case of branch performance

When doing my last performance tests for bool packing, I got strange results sometimes. It appeared that one constant generated different results than the other. Why was that? Let’s have a quick look at branching performance. The problem Just to recall (first part, second part) I wanted to pack eight booleans (results of a condition) into one byte, 1 bit per condition result.

READ MORE...

Packing bools, Parallel and More

Let’s continue with the topic of packing boolean arrays into bits. Last time I’ve shown a basic - single threaded version of this ‘super’ advanced algorithm. By using more independent variables, we could speed things up and go even faster than no packing version! We’ve also used std::vector and std::bitset.

READ MORE...

Packing Bools, Performance tests

Imagine you have an array of booleans (or an array of ‘conditions’), and you want to pack it - so you use only one bit per boolean. How to do it? Let’s do some experiments! Updated: 8th May 2017 Read the second part here and also one update. Motivation I started writing this post because I came across a similar problem during my work some time ago.

READ MORE...