How to avoid Query Plan re-compilation when using IEnumerable.Contains in Entity Framework LINQ queries?

This is a great question. First of all, here are a couple of workarounds that come to mind (they all require changes to the query): First workaround This one maybe a bit obvious and unfortunately not generally applicable: If the selection of items you would need to pass over to Enumerable.Contains already exists in a … Read more

How much overhead can the -fPIC flag add?

It turns out that when you compile without the -fPIC option multiplyComplex, sqComplex, isInSet and isMandelbrot are inlined automatically by the compiler. If you define those functions as static you will likely get the same performance when compiling with -fPIC because the compiler will be free to perform inlining. The reason why the compiler is … Read more

Network throttling with chrome and selenium

The API to control network emulation were added to ChromeDriver. And should be available for quite a while now. According to comment in the linked issue you should use version at least 2.26 because of some bugfix. According to Selenium changelog bindings are available for these languages: JavaScript as of version 3.4.0 (commit) Python as … Read more

Why is pow(int, int) so slow?

pow() works with real floating-point numbers and uses under the hood the formula pow(x,y) = e^(y log(x)) to calculate x^y. The int are converted to double before calling pow. (log is the natural logarithm, e-based) x^2 using pow() is therefore slower than x*x. Edit based on relevant comments Using pow even with integer exponents may … Read more

deque.popleft() and list.pop(0). Is there performance difference?

deque.popleft() is faster than list.pop(0), because the deque has been optimized to do popleft() approximately in O(1), while list.pop(0) takes O(n) (see deque objects). Comments and code in _collectionsmodule.c for deque and listobject.c for list provide implementation insights to explain the performance differences. Namely that a deque object “is composed of a doubly-linked list”, which … Read more