Why is a conditional move not vulnerable to Branch Prediction Failure?

Mis-predicted branches are expensive A modern processor generally executes between one and three instructions each cycle if things go well (if it does not stall waiting for data dependencies for these instructions to arrive from previous instructions or from memory). The statement above holds surprisingly well for tight loops, but this shouldn’t blind you to … Read more

Fastest way to grow a numpy numeric array

I tried a few different things, with timing. import numpy as np The method you mention as slow: (32.094 seconds) class A: def __init__(self): self.data = np.array([]) def update(self, row): self.data = np.append(self.data, row) def finalize(self): return np.reshape(self.data, newshape=(self.data.shape[0]/5, 5)) Regular ol Python list: (0.308 seconds) class B: def __init__(self): self.data = [] def update(self, … Read more

Inefficient jQuery usage warnings in PHPStorm IDE

I had the same question today and was able to find a solution thanks to Scott Kosman here. Basically the answer is to select IDs individually and then use .find(…) for anything below. So taking your example: $(“#property [data-role=”content”] .container”); Changing it to this makes PhpStorm happy and can evidently be more than twice as … Read more

Visual Studio 2017 is too slow during building and debugging

In order to obtain a better performance in Visual Studio 2017, some kind of Performance Tweaks can be applied as shown below: Set Current source control … to None under Tools → Options → Source Control Uncheck Synchronized settings across … option under Tools → Options → Environment → Synchronized Settings (for some versions: Tools … Read more

Interactive large plot with ~20 million sample points and gigabytes of data

So your data isn’t that big, and the fact that you’re having trouble plotting it points to issues with the tools. Matplotlib has lots of options and the output is fine, but it’s a huge memory hog and it fundamentally assumes your data is small. But there are other options out there. So as an … Read more

What is the fastest method for selecting descendant elements in jQuery?

Method 1 and method 2 are identical with the only difference is that method 1 needs to parse the scope passed and translate it to a call to $parent.find(“.child”).show();. Method 4 and Method 5 both need to parse the selector and then just call: $(‘#parent’).children().filter(‘.child’) and $(‘#parent’).filter(‘.child’) respectively. So method 3 will always be the … Read more

Why is vectorization, faster in general, than loops?

Vectorization (as the term is normally used) refers to SIMD (single instruction, multiple data) operation. That means, in essence, that one instruction carries out the same operation on a number of operands in parallel. For example, to multiply a vector of size N by a scalar, let’s call M the number of operands that size … Read more

What’s the difference between BaseAdapter and ArrayAdapter?

Here is the difference: BaseAdapter is a very generic adapter that allows you to do pretty much whatever you want. However, you have to do a bit more coding yourself to get it working. ArrayAdapter is a more complete implementation that works well for data in arrays or ArrayLists. Similarly, there is a related CursorAdapter … Read more

SQL ‘like’ vs ‘=’ performance

See https://web.archive.org/web/20150209022016/http://myitforum.com/cs2/blogs/jnelson/archive/2007/11/16/108354.aspx Quote from there: the rules for index usage with LIKE are loosely like this: If your filter criteria uses equals = and the field is indexed, then most likely it will use an INDEX/CLUSTERED INDEX SEEK If your filter criteria uses LIKE, with no wildcards (like if you had a parameter in a … Read more