你见过最可笑的悲观主义是什么? [英] What is the most ridiculous pessimization you've seen?

查看:19
本文介绍了你见过最可笑的悲观主义是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们都知道过早优化是万恶之源,因为它会导致代码不可读/不可维护.更糟糕的是悲观,当有人实施优化"是因为他们认为它会更快,但最终却变得更慢,还有错误、不可维护等.最荒谬的例子是什么?你见过这个吗?

We all know that premature optimization is the root of all evil because it leads to unreadable/unmaintainable code. Even worse is pessimization, when someone implements an "optimization" because they think it will be faster, but it ends up being slower, as well as being buggy, unmaintainable, etc. What is the most ridiculous example of this that you've seen?

推荐答案

在一个旧项目中,我们继承了一些(其他方面都很优秀)嵌入式系统程序员,他们拥有丰富的 Z-8000 经验.

On an old project we inherited some (otherwise excellent) embedded systems programmers who had massive Z-8000 experience.

我们的新环境是 32 位 Sparc Solaris.

Our new environment was 32-bit Sparc Solaris.

其中一个人将所有整数都改为shorts以加快我们的代码速度,因为从RAM中获取16位比获取32位更快.

One of the guys went and changed all ints to shorts to speed up our code, since grabbing 16 bits from RAM was quicker than grabbing 32 bits.

我必须编写一个演示程序来证明在 32 位系统上获取 32 位值比获取 16 位值更快,并解释要获取 16 位值 CPU 必须生成一个 32-位宽内存访问,然后屏蔽或移位 16 位值不需要的位.

I had to write a demo program to show that grabbing 32-bit values on a 32-bit system was faster than grabbing 16-bit values, and explain that to grab a 16-bit value the CPU had to make a 32-bit wide memory access and then mask out or shift the bits not needed for the 16-bit value.

这篇关于你见过最可笑的悲观主义是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆