性能改进 计算胡言乱语
前几天,我将一段特定代码的性能从 34 秒提高到 2 秒,我正在计算相同的百分比,即 (34-2)/34,即 94.11 百分比,当我在一次会议上告诉人们这个数字时没有那么惊讶..我想知道我传达的数字是否有误..
您通常如何衡量改进并同时看起来不错?
Well the other day I improved the performance of a particualr piece of code from 34sec to 2 sec and I was calcuating the percentage for the same i.e (34-2)/34 i.e 94.11 percentage and when I told this number out in a meeting people were not that amazed.. I am wondering if that was a wrong number that I communicated..
How do you generally measure the improvement and look good at the same time?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
速度(或吞吐量)与时间的倒数成正比。因此,它实际上是速度提高了
34/2 = 17x
倍(如果您想让声音听起来更好,您可以将其表示为(34-2)/2 = 1600%
速度提升)感人的)。Speed (or throughput) is proportional to the reciprocal of time. So it's actually a factor of
34/2 = 17x
faster (which you can state as a(34-2)/2 = 1600%
speed increase if you want to sound impressive).首先,你必须非常小心你的措辞方式。说某个东西快了一倍就等于说它提高了 100%,这也等于说它是原来的 200%(无论引用的是什么)。当您说“改进”或“增加”时,您就隐含地引用了原始金额+改进。
例子:
你有 3 美元。你的钱翻倍到 6 美元。这是 100% 的改进(或 100% 的增加),因为您有原始的 3 美元 + 新的 3 美元(等于原始金额的 100%)。但您也可以说您的金额是以前的 200%,因为 $3*200% = $3*2 = $6。
现在,就速度而言,用旧的代数方程来思考:
速率*时间=距离。除了我们之外,“距离”更像是“完成的工作”。
因此,如果某项特定作业最初需要 1 秒,而您进行了更改以使其在 0.5 秒内执行相同的作业:
原始
R*1sec = 1job
R = 1job/1sec = 1 job/sec
新
R*0.5sec = 1job
R = 1job/0.5sec = 2 job/sec
因此,您的速度增加了一倍。您可以说速度增加了 100%,或者速度增加了一倍,或者速度比以前快了 200%。
--------------------编辑以使用OP的数字------
原始
R*34sec = 1job
R = 1job/34sec = 1/34 job/sec = 0.029 作业/秒
新
R*2 秒 = 1 作业
R = 1 作业/2 秒 = 1/2 作业/秒 = 0.5 作业/秒
因此,比较 0.029 作业/秒与 0.5 作业/秒的速率
0.5/0.029 = 17
因此,新代码的运行速度快了 17 倍,或者快了 1700%,或者提高了 1600%。
First off, you have to be very careful how you phrase it. To say that something is twice as fast is the same as saying it improved by 100% which is the same as saying it is 200% of what it was (whatever that reference is to). When you say "improved" or "increased" then you have an implicit reference to the original amount + improvement.
Example:
You have $3. You double your money to $6. That is a 100% improvement (or a 100% increase) because you have the original $3 + new $3 (which is equal to 100% of the original amount). But you could also say you have 200% as much as you had before because $3*200% = $3*2 = $6.
Now, as far as speed goes, think of this in terms of the old Algebra equation:
Rate*Time=Distance. Except for us, "Distance" is more like "Job performed".
So, if a specific job takes 1 second originally and you changed things to make it perform that same job in 0.5 seconds:
Original
R*1sec = 1job
R = 1job/1sec = 1 job/sec
New
R*0.5sec = 1job
R = 1job/0.5sec = 2 job/sec
Thus, your speed doubled. You could say the rate increased by 100% or that the rate doubled or that it is 200% as fast as it used to be.
--------------------edit to use OP's numbers------
Original
R*34sec = 1job
R = 1job/34sec = 1/34 job/sec = 0.029 job/sec
New
R*2sec = 1job
R = 1job/2sec = 1/2 job/sec = 0.5 job/sec
So, to compare the rates 0.029 job/sec to 0.5 job/sec
0.5/0.029 = 17
Thus the new code runs 17x faster, or is 1700% as fast, or is increased by 1600%.
我想我会说“我将速度提高了 16 倍以上”或“我让它快了一个数量级(当然是以 16 为基数)”。如果你想同时看起来不错,你可能需要去买新衣服。 (当然,我已经和营销小东西混在一起太久了——所以我使用“更好”这样的短语,因为这听起来像是没有极限。)
I think I would have said "I increased the speed by better than a factor of 16" or "I made it an order of magnitude (base 16 of course) faster." If you want to look good at the same time you probably need to go buy new clothes. (Of course I've hung out with marketing weenies for too long - so I use phrases like "better than" because it sounds like the sky's the limit.)
“在十七分之一的时间内执行”或简单的“与之前的三十四秒相比需要两秒”怎么样?
How about "executes in one seventeenth of the time" or plain "requires two seconds compared to thirty-four previously"?