了解你的计算机执行一条指令要多长时间

本文多数内容源自CoolShell.com 和 norvig.com

只是在此做了摘要和精简。^_^

 

乔叟(Chaucer,英国诗人,1340-1400)曾抱怨说:

“生命如此短暂,掌握技艺却要如此长久。”

the lyf so short, the craft so long to lerne.

——前言

 

 

请务必记住在“计算机科学”这个词组里包含的“计算机”这个词。

最好了解你的计算机执行一条指令要多长时间,

从内存中取一个word要多长时间(包括缓存命中和未命中的情况),

从磁盘上读取连续的数据要多长时间,定位到磁盘上的新位置又要多长时间等。

 

Approximate timing for various operations on a typical PC:

 

execute typical instruction

1/1,000,000,000 sec = 1 nanosec

fetch from L1 cache memory

0.5 nanosec

branch misprediction

5 nanosec

fetch from L2 cache memory

7 nanosec

Mutex lock/unlock

25 nanosec

fetch from main memory

100 nanosec

send 2K bytes over 1Gbps network

20,000 nanosec

read 1MB sequentially from memory

250,000 nanosec

fetch from new disk location (seek)

8,000,000 nanosec

read 1MB sequentially from disk

20,000,000 nanosec

send packet US toEurope  and back

150 milliseconds = 150,000,000 nanosec

你可能感兴趣的:(计算机)