Software Engineering Cheat Sheet: Time, Data Size & Complexity

Software Engineering Reference Cheat Sheet

Time Conversion

UnitDaysHoursMinutesSeconds (s)Milliseconds (ms)Microseconds (μs)Nanoseconds (ns)
1 Day1241,44086,40086,400,00086,400,000,00086,400,000,000,000
1 Hour1/241603,6003,600,0003,600,000,0003,600,000,000,000
1 Minute1/1,4401/6016060,00060,000,00060,000,000,000
1 Second1/86,4001/3,6001/6011,0001,000,0001,000,000,000
1 Millisecond1/86,400,0001/3,600,0001/60,0000.00111,0001,000,000
1 Microsecond1/86,400,000,0001/3,600,000,0001/60,000,0000.0000010.00111,000
1 Nanosecond1/86,400,000,000,0001/3,600,000,000,0001/60,000,000,0000.0000000010.0000010.0011

Data Size Conversion

UnitBits (b)Bytes (B)Kilobytes (KB)Megabytes (MB)Gigabytes (GB)Terabytes (TB)Petabytes (PB)
1 Bit11/81 / (8 × 1,024)1 / (8 × 1,0242)1 / (8 × 1,0243)1 / (8 × 1,0244)1 / (8 × 1,0245)
1 Byte811/1,0241/1,02421/1,02431/1,02441/1,0245
1 Kilobyte8,1921,02411/1,0241/1,02421/1,02431/1,0244
1 Megabyte8,388,6081,048,5761,02411/1,0241/1,02421/1,0243
1 Gigabyte8,589,934,5921,073,741,8241,048,5761,02411/1,0241/1,0242
1 Terabyte8.796… × 10121,099,511,627,7761,073,741,8241,048,5761,02411/1,024
1 Petabyte9.007… × 10151,125,899,906,842,6241,073,741,824,0001,073,741,8241,048,5761,0241

System Latency Numbers Every Programmer Should Know

OperationApproximate TimeHuman Scale Equivalent (if 1 CPU cycle = 1s)
L1 Cache reference0.5 – 1 ns1 second
Branch mispredict3 – 5 ns3 – 5 seconds
L2 Cache reference3 – 7 ns7 seconds
RAM / Main Memory reference50 – 100 ns1 – 2 minutes
SSD Random Read16 – 100 µs1.5 – 2.5 days
Read 1 MB sequentially from Memory250 µs3 days
Read 1 MB sequentially from SSD1,000 µs (1 ms)12 days
Network round trip within same Data Center500 µs6 days
Read 1 MB sequentially from Disk (HDD)20,000 µs (20 ms)8 months
Packet round trip (CA to NY)40 ms1.2 years

Powers of 2 / Binary Memory Reference

Power (2x)Exact Value / Approx ValueBinary RepresentationCommon CS Meaning
2825600000000 100000001 Byte max value (uint8)
2101,024 (1 KiB ≈ 103)00000100 000000001 KiB
21665,53600000000 00000000 10000000 00000000Port numbers / uint16 max
2201,048,576 (1 MiB ≈ 106)—1 MiB
2301,073,741,824 (1 GiB ≈ 109)—1 GiB
231−12,147,483,64701111111 11111111 11111111 11111111Signed 32-bit int max (INT_MAX)
2324,294,967,296 (≈ 4.3 B)—IPv4 address space / 4 GB RAM limit
2401.099… × 1012 (1 TiB ≈ 1012)—1 TiB
264−1≈ 1.84 × 1019—Unsigned 64-bit int max (uint64)

Common Big-O Time & Space Complexity

Algorithm / OperationAverage TimeWorst TimeSpace Complexity
Array Lookup / AppendO(1)O(1) / O(n)O(n)
Hash Table Search / InsertO(1)O(n)O(n)
Binary Search TreeO(log n)O(n)O(n)
Binary Search (Sorted Array)O(log n)O(log n)O(1)
QuicksortO(n log n)O(n2)O(log n)
MergesortO(n log n)O(n log n)O(n)
Matrix MultiplicationO(n3)O(n3)O(n2)

Common Network & Throughput Bitrates

Connection / InterfaceSpeed (Bits per sec)Max Transfer Rate (Bytes per sec)
1 Gbps Ethernet1 Gbps125 MB/s
PCIe 4.0 (x16)256 Gbps31.5 GB/s
USB 3.2 Gen 210 Gbps1.25 GB/s
USB4 / Thunderbolt 440 Gbps5 GB/s
DDR4 RAM (Single Channel)~200–300 Gbps~25–38 GB/s