开发者

Reference for relative operation expense

开发者 https://www.devze.com 2023-03-26 23:59 出处:网络
Does anyone know a good reference to help with understanding the relative cost of operations like copying variables, declaring new variables, FileIO, array operations, etc? I\'ve been told to study de

Does anyone know a good reference to help with understanding the relative cost of operations like copying variables, declaring new variables, FileIO, array operations, etc? I've been told to study decompilat开发者_如何学运维ion and machine code but a quick reference would be nice. For example, something to tell me how much worse

for(int i = 0; i < 100; i++){
    new double d = 7.65;
    calc(d);
}

is than

double d = 7.65;
for(int i = 0; i < 100; i++){
    calc(d);
}


Here is a nice paper by Felix von Leitner on the state of C compiler optimization. I learned of it on this Lambda the Ultimate page.

The performance of operations you mention such as file I/O, memory access, and computation are highly dependent on a computer's architecture. Much of the optimization of software for today's desktop computers is focused on cache memory.

You would gain much from an architecture book or course. Here's a good example from CMU.

0

精彩评论

暂无评论...
验证码 换一张
取 消