Speed difference in using inline strings vs concatenation in php5?

The performance difference has been irrelevant since at least January 2012, and likely earlier: Single quotes: 0.061846971511841 seconds Double quotes: 0.061599016189575 seconds Earlier versions of PHP may have had a difference – I personally prefer single quotes to double quotes, so it was a convenient difference. The conclusion of the article makes an excellent point: …

Read more

multiprocessing.Pool() slower than just using ordinary functions

These problems usually boil down to the following: The function you are trying to parallelize doesn’t require enough CPU resources (i.e. CPU time) to rationalize parallelization! Sure, when you parallelize with multiprocessing.Pool(8), you theoretically (but not practically) could get a 8x speed up. However, keep in mind that this isn’t free – you gain this …

Read more

Java 8 stream unpredictable performance drop with no obvious reason

This effect is caused by Type Profile Pollution. Let me explain on a simplified benchmark: @State(Scope.Benchmark) public class Streams { @Param({“500”, “520”}) int iterations; @Setup public void init() { for (int i = 0; i < iterations; i++) { Stream.empty().reduce((x, y) -> x); } } @Benchmark public long loop() { return Stream.empty().count(); } } Though …

Read more

What is IACA and how do I use it?

2019-04: Reached EOL. Suggested alternative: LLVM-MCA 2017-11: Version 3.0 released (latest as of 2019-05-18) 2017-03: Version 2.3 released What it is: IACA (the Intel Architecture Code Analyzer) is a (2019: end-of-life) freeware, closed-source static analysis tool made by Intel to statically analyze the scheduling of instructions when executed by modern Intel processors. This allows it …

Read more

Why is a `for` loop so much faster to count True values?

sum is quite fast, but sum isn’t the cause of the slowdown. Three primary factors contribute to the slowdown: The use of a generator expression causes overhead for constantly pausing and resuming the generator. Your generator version adds unconditionally instead of only when the digit is even. This is more expensive when the digit is …

Read more