e-commerce: Algorithm for calculating discounts

Assuming that: You can compute all available discounts based on your basket Each product can only have a single discount applied to it Each discount can only be used once Then the problem becomes one that is called an assignment problem and can be optimally solved in O(n^3) using the Hungarian algorithm. You will need … Read more

What does OpenJDK JMH “score error” exactly mean?

This is the margin of error for the score. In most cases, that is a half of confidence interval. Think about it as if there is a “±” sign between “Score” and “Score error”. In fact, the human-readable log will show that: Result: 1.986 ±(99.9%) 0.009 ops/ns [Average] Statistics: (min, avg, max) = (1.984, 1.986, … Read more

Sending data with PACKET_MMAP and PACKET_TX_RING is slower than “normal” (without)

Many interfaces to the linux kernel are not well documented. Or even if they seem well documented, they can be pretty complex and that can make it hard to understanding what the functional or, often even harder, nonfunctional properties of the interface are. For this reason, my advice to anyone wanting a solid understanding of … Read more

How to speed up / parallelize downloads of git submodules using git clone –recursive?

With git 2.8 (Q12016), you will be able to initiate the fetch of submodules… in parallel! See commit fbf7164 (16 Dec 2015) by Jonathan Nieder (artagnon). See commit 62104ba, commit fe85ee6, commit c553c72, commit bfb6b53, commit b4e04fb, commit 1079c4b (16 Dec 2015) by Stefan Beller (stefanbeller). (Merged by Junio C Hamano — gitster — in … Read more

Why is numpy.array so slow?

Numpy is optimised for large amounts of data. Give it a tiny 3 length array and, unsurprisingly, it performs poorly. Consider a separate test import timeit reps = 100 pythonTest = timeit.Timer(‘a = [0.] * 1000000’) numpyTest = timeit.Timer(‘a = numpy.zeros(1000000)’, setup=’import numpy’) uninitialised = timeit.Timer(‘a = numpy.empty(1000000)’, setup=’import numpy’) # empty simply allocates the … Read more