Hacker News new | ask | show | jobs
by enedil 1312 days ago
Went from 4.139s to 2.413s. I fail to see how it is 70%. I think it is explained as 4.139/2.413 = 1.7 which of course doesn't make sense here.
5 comments

I do think saying it's 71% faster makes sense here, since "x% faster" and "speed increased by x%" mean the same thing. This reduces the runtime by 42%, but that doesn't mean it's just 42% faster.
It would probably be more accurate to say it can do 70% more stuff in the same time. Or that it takes 42% less runtime
But 70% more stuff in the same time is 70% faster.
Let's say you do 10 things in 100 time (100/10 =10 time per thing) to start with:

70% more stuff in the same time is 17 things in 100 time (100/17 =5.9 time per thing);

70% faster is 10 things in 30 time (30/10 =3 time per thing) - or, I would argue incorrectly, perhaps said to mean 10 things in 70 time (70/10 =7 time per thing).

90mph is 50% faster than 60mph. 17/time is 70% faster than 10/time.

You're describing "in 70% less time", not "70% faster".

This is an extremely common mistake in reporting performance numbers. That the old version is 70% slower does not make the new version 70% faster.
70% slower is a bit ambiguous though - it could mean 70% extra runtime or it could mean 30% of the new speed. Whereas 70% faster would always suggest to me that it can do 70% more work in the same amount of time, i.e. a 1.7x increase in speed.
I do not agree. When you benchmark you usually measure the differences between times needed to complete. This is because it is highly non-obvious that if you increase workload twice, the time increases also twice. Perhaps the algorithm is not linear. Perhaps if you have more data, you suddenly need to swap memory. Perhaps something (like disk access in parallel) means that actually it takes less than 2x time. This means that a concept of speed per unit of work is undefined. So the only reasonable interpretation of "70% faster" means "spends 30% time of original".
I can categorically state I've never thought of or understand 70% faster as meaning that, and certainly not 100% faster as meaning "completes instantly".

I see the OP has solved the problem by removing any references to how much faster from the article title!

You're right about non-linear algorithms though. If an O(n^2) algorithm is 2x / 100% faster, it can't process 100% more items in the same time, but I'd understand it to mean taking half the time for the same n.

But under your definition, if something becomes "three times as fast" (i.e., 200% faster), it will have to finish its task in negative time!
Doh! Thanks for pointing out another silly mistake – I'll fix that.
You had it right the first time, 1.7x speed is 70% faster.

If something previously took 4s now takes 2s then it's 100% faster.

Think of driving 10miles. If you drive at 20mph then it takes 30 minutes. If you drive twice as fast, 40mph, it takes 15 minutes.

40mph is 100% faster than 20mph.

Half the time is twice as fast!

Glad it wasn't just me thinking this!
I disagree, I think the 70% is right, and matches what you still describe as a 1.7x speed increase. If it originally took 4 seconds and now takes 2, I'd call that a 100% speed increase, i.e. twice as fast.
@hcm: Would have loved to see the 'after' flamegraph just for comparison purposes! I'm still trying to get used to groking flamegraphs when optimizing. They're a somewhat new tool, IMO.
It's gone from 14.5 operations per minute to 24.9 operations per minute so a 70% speedup.