Computers are fast - A cheatsheet
Data rates of various systems
This is inspired by Julia Evans and Kamal Marhubiβs excellent mini-quiz on the data rates of systems and components.
The below cheatsheet serves as a summary of those benchmark speeds, for at-a-glance consumption.
Orders of magnitude
The idea is not necessarily know the exact figures for a particular benchmark, just the right order of magnitude.
π 100 1
π¦₯ 101 10
πΆ 102 100
πββοΈ 103 1,000
πβ 104 10,000
βποΈπ¨ 105 100,000
π 106 1,000,000
βοΈ 107 10,000,000
π 108 100,000,000
π 109 1,000,000,000
βHow much can be done in a secondβ
sum.c
- Each loop adds to total
- How many loop iterations per second?
- π - π
- Between 100 million and 1 Billion
- 108 > and < 109
loop.py
- Empty loop contents
- How many loop iterations per second?
- βοΈ - π
- Between 10m and 100m
- 107 > and < 108
dict.py
- Add elements to a fixed-size dictionary
- How many loop iterations per second?
- βοΈ - π
- Between 10m and 100m
- 104 > and < 105
parse_http_request.py
- Using Python built-in HTTP request parser
- How many HTTP requests parsed per second?
- πβοΈ - βποΈπ¨β
- Between 10,000 and 100,000
- 104 > and < 105
download_webpage.py
- Downloading with urllib2
- How many HTTP requests completed per second?
- πβοΈ - βπ¦₯
- Between 1 and 10
-
The true cost depends on size, connection speed and distance from servers
run_python.sh
- Running Python script(s) from bash
- Bash loop iterations per second
- π¦₯ - βπΆβ
- Between 10 and 100
- 101 > and < 102
write_to_disk.py
- Code run on a machine with an SSD
- How many bytes written to disk in a second
- π - π
- Between 100 million and 1 Billion
- How many megabytes written to disk in a second
- πΆ - πββοΈ
- Between 100 and 1,000
- My T480s running Ubuntu with SSD reports write speed: 2.3 GB/s and read 673 MB/s 1
write_to_memory.py
- How many bytes written to a string in memory in a second
- π +
- Above 1 Billion
grep_bytes.sh
- Bytes search in a second
- π +
- Above 1 Billion
find-filenames.sh
- Files come from the filesystem cache
- How many files listed in one second?
- ππ¨ - βπ
- Between 100,000 and 1m
- 105 > and < 106
-
Grep can search at 2GB/s so more limited by disk speed than grepβs speed
json_parse.py
- Deserializing the same 65k of JSON repeatedly
- How many loop iterations in a second?
- πΆ - βπββοΈ
- Between 100 and 1,000
- 102 > and < 103
msgpack_parse.py
- Parse 46k of msgpack data
- How many loop iterations in a second?
- πββοΈ - βπβ
- Between 1,000 and 10,000
- 103 > and < 104
-
Your choice of format and deserialisation library (eg capnproto) makes a big difference
database_indexed.py
- Select one row from an indexed sqlite table containing 10m rows
- How many queries in one second
- βπβ - ποΈπ¨
- Between 10,000 and 100,000
- 104 > and < 105
- Typical query in 20 microseconds
database_unindexed.py
- Select one row from an unindexed sqlite table containing 10m rows
- How many queries in one second
- πβοΈ - βπ¦₯
- Between 1 and 10
- 100 > and < 101
hash.py
- How many bytes hashed in one second?
- π - π
- Between 100 million and 1 Billion
- 108 > and < 109
-
MD5 is designed to be fast
bcrypt_hash.py
- Number of passwords hashed in a second?
- πβοΈ - βπ¦₯
- Between 1 and 10
- 100 > and < 101
fill_array.c
- Memory is accessed sequentially from a CPU cache
- Number of passwords hashed in a second?
- π - π
- Between 100 million and 1 Billion
- 108 > and < 109
fill_array.c
- Number of passwords hashed in a second?
- βοΈ - π
- Between 10m and 100m
- 104 > and < 105
Resources used: with thanks π
- Do you know how much your computer can do in a second? - Mini Quiz