top | item 31732484

(no title)

mathiasrw | 3 years ago

You cant make code faster. You can only make it do less things.

discuss

order

yjftsjthsd-h|3 years ago

That's either wrong, or right in a way that requires playing with definitions until it's meaningless. Take the traditional example, sorting algorithms; they all do the same thing, but at wildly varying speeds. The only way to claim that some do less is to claim that they use fewer instructions (loosely speaking; pretend that CPU operations are constant time and nothing else matters), at which point you're right but claiming a meaningless tautology. Removing work is a strategy for optimization (sometimes a good one!), but it's not the end-all be-all.

hinkley|3 years ago

You can. You can make it do different things, you can make it do the same things in a better order.

Most real software has a complicated relationship with Amdahl's Law, and there are often ways to reduce latency without really changing the ops/sec. That's true for IPC, but also true for the processor itself. Sometimes using the 'wrong' instruction for an operation increases the instructions per cycle.