Re:Making a Go program 70% faster with a one character change
by enedil on Monday November 14, 2022 @11:12AM
(#33596179)
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.
[ Parent
| on HN ]
Re:Making a Go program 70% faster with a one character change
by hcm on Monday November 14, 2022 @11:22AM
(#33596383)
Doh! Thanks for pointing out another silly mistake – I'll fix that.
Re:Making a Go program 70% faster with a one character change
by xnorswap on Monday November 14, 2022 @12:22PM
(#33597479)
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!
Re:Making a Go program 70% faster with a one character change
by wizofaus on Monday November 14, 2022 @12:31PM
(#33597645)
Glad it wasn't just me thinking this!
Re:Making a Go program 70% faster with a one character change
by wizofaus on Monday November 14, 2022 @12:31PM
(#33597627)
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.
Re:Making a Go program 70% faster with a one character change
by markoman on Monday November 14, 2022 @03:53PM
(#33600850)
@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.
Re:Making a Go program 70% faster with a one character change
by bmicraft on Monday November 14, 2022 @11:15AM
(#33596238)
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
Re:Making a Go program 70% faster with a one character change
by xnorswap on Monday November 14, 2022 @12:23PM
(#33597491)
But 70% more stuff in the same time is 70% faster.
Re:Making a Go program 70% faster with a one character change
by OJFord on Monday November 14, 2022 @03:15PM
(#33600318)
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).
Re:Making a Go program 70% faster with a one character change
by LanceH on Tuesday November 15, 2022 @12:13AM
(#33605571)
90mph is 50% faster than 60mph. 17/time is 70% faster than 10/time.
You're describing "in 70% less time", not "70% faster".
Re:Making a Go program 70% faster with a one character change
by morelisp on Monday November 14, 2022 @11:17AM
(#33596275)
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.
Re:Making a Go program 70% faster with a one character change
by wizofaus on Monday November 14, 2022 @12:36PM
(#33597737)
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.
Re:Making a Go program 70% faster with a one character change
by enedil on Monday November 14, 2022 @02:46PM
(#33599849)
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".
Re:Making a Go program 70% faster with a one character change
by yongjik on Monday November 14, 2022 @04:09PM
(#33601104)
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!
Re:Making a Go program 70% faster with a one character change
by wizofaus on Monday November 14, 2022 @04:12PM
(#33601157)
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!
Re:Making a Go program 70% faster with a one character change
by CodesInChaos on Monday November 14, 2022 @04:05PM
(#33601041)
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.