C# Performance on Small Functions

One of my co-workers has been reading Clean Code by Robert C Martin and got to the section about using many small functions as opposed to fewer large functions. This led to a debate about the performance consequence of this methodology. So we wrote a...
more »

2017-07-18 19:07 (1) Answers

How to force Postgres using index?

I have the following query that find all id insidePOLYGON(({points})) SELECT id FROM t WHERE ST_DWithin('POLYGON(({points}))', ST_Point(latitude, longitude), 0); The query is slow because it doesn't use (latitude, longitude) index and must compute...
more »

2017-07-18 11:07 (2) Answers

Why is Ruby's loop command slower than while true?

Ruby has a built-in loop command that executes the block following it forever (or until stopped by break). However, when comparing it against the functionally similar while true, it is significantly slower: require "benchmark/ips" NUMBER = 100_000_...
more »

2017-07-13 02:07 (2) Answers

SIMD Linear Search Slower than Unrolled Loop

I'm working on an application for which a highly optimized linear search will make a big difference in the overall performance, and I've been tasked with improving performance as much as I can. I'm running my search on a vector of 10,000 elements th...
more »

2017-07-12 09:07 (2) Answers

How to speed up creation of a FileStream

My application needs to open a lot of small files, say 1440 files each containing data of 1 minute to read all the data of a certain day. Each file is only a couple of kB big. This is for a GUI application, so I want the user (== me!) to not have to ...
more »

2017-07-09 13:07 (3) Answers

Low Allocation Drawing in WPF

I am having some serious issues with WPF and using DrawingContext, or specifically VisualDrawingContext coming from overriding OnRender on an element or if using DrawingVisual.RenderOpen(). The problem is this allocates a lot. For example, it seems...
more »

2017-07-06 21:07 (2) Answers

How to find matching items for prefixes in query

I didn't know how to explain it in the question title. Say I have a query of 'Red interest cake' (sorry). I want to search a big database of items (say descriptions). I need to find all descriptions/items that have either this entire query as part of...
more »

2017-07-01 22:07 (1) Answers

Python: any() unexpected performance

I am comparing the performance of the any() built-in function with the actual implementation the docs suggest: I am looking for an element greater than 0 in the following list: lst = [0 for _ in range(1000000)] + [1] This is the supposedly equiva...
more »

2017-06-28 14:06 (4) Answers

Why is strtolower slightly slower than strtoupper?

I did an experiment out of curiosity. I wanted to see if there was a micro difference at all between strtolower() and strtoupper(). I expected strtolower() would be faster on mostly lowercase strings and visa versa. What I found is that strtolower() ...
more »

2017-06-27 15:06 (2) Answers