performance
How does Go compile so quickly?
Dependency analysis. The Go FAQ used to contain the following sentence: Go provides a model for software construction that makes dependency analysis easy and avoids much of the overhead of C-style include files and libraries. While the phrase is not in the FAQ anymore, this topic is elaborated upon in the talk Go at Google, … Read more
Recursion or Iteration?
Loops may achieve a performance gain for your program. Recursion may achieve a performance gain for your programmer. Choose which is more important in your situation!
Why JSF calls getters multiple times
This is caused by the nature of deferred expressions #{} (note that “legacy” standard expressions ${} behave exactly the same when Facelets is used instead of JSP). The deferred expression is not immediately evaluated, but created as a ValueExpression object and the getter method behind the expression is executed everytime when the code calls ValueExpression#getValue(). … Read more
Is it safe to shallow clone with –depth 1, create commits, and pull updates again?
Note that Git 1.9/2.0 (Q1 2014) has removed that limitation. See commit 82fba2b, from Nguyễn Thái Ngọc Duy (pclouds): Now that git supports data transfer from or to a shallow clone, these limitations are not true anymore. The documentation now reads: –depth <depth>:: Create a ‘shallow’ clone with a history truncated to the specified number … Read more
Why is Haskell (GHC) so darn fast?
I agree with Dietrich Epp: it’s a combination of several things that make GHC fast. First and foremost, Haskell is very high-level. This enables the compiler to perform aggressive optimisations without breaking your code. Think about SQL. Now, when I write a SELECT statement, it might look like an imperative loop, but it isn’t. It … Read more
What’s the most efficient way to test if two ranges overlap?
What does it mean for the ranges to overlap? It means there exists some number C which is in both ranges, i.e. x1 <= C <= x2 and y1 <= C <= y2 To avoid confusion, considering the ranges are: [x1:x2] and [y1:y2] Now, if we are allowed to assume that the ranges are well-formed … Read more
What is the fastest way to get the value of π?
The Monte Carlo method, as mentioned, applies some great concepts but it is, clearly, not the fastest, not by a long shot, not by any reasonable measure. Also, it all depends on what kind of accuracy you are looking for. The fastest π I know of is the one with the digits hard coded. Looking … Read more
Is recursion ever faster than looping?
This depends on the language being used. You wrote ‘language-agnostic’, so I’ll give some examples. In Java, C, and Python, recursion is fairly expensive compared to iteration (in general) because it requires the allocation of a new stack frame. In some C compilers, one can use a compiler flag to eliminate this overhead, which transforms … Read more
HTTP vs HTTPS performance
There’s a very simple answer to this: Profile the performance of your web server to see what the performance penalty is for your particular situation. There are several tools out there to compare the performance of an HTTP vs HTTPS server (JMeter and Visual Studio come to mind) and they are quite easy to use. … Read more