Thursday, 22 August 2013

Table column align on decimal

Table column align on decimal

Jeff Dean published this famous table of "numbers every software developer
should know". I'm struggling to format it properly for a publication that
is written in LaTeX.
As you can see, the left column is easy. It is left justified.
The right column needs to be aligned on the word "ns" with an occasional
note after it. Also the first line has a decimal, while the other numbers
are integers.
Here's my best attempt so far:
\begin{tabular}{ | l | r |}
\hline
L1 cache reference & 0.5 ns \\
Branch mispredict & 5 ns \\
L2 cache reference & 7 ns \\
Mutex lock/unlock & 100 ns (25) \\
Main memory reference & 100 ns \\
Compress 1K bytes with Zippy & 10,000 ns (3,000) \\
Send 2K bytes over 1 Gbps network & 20,000 ns \\
Read 1 MB sequentially from memory & 250,000 ns \\
Round trip within same datacenter & 500,000 ns \\
Disk seek & 10,000,000 ns \\
Read 1 MB sequentially from network & 10,000,000 ns \\
Read 1 MB sequentially from disk & 30,000,000 ns (20,000,000) \\
Send packet CA to Netherlands to CA & 150,000,000 ns \\
\hline
\end{tabular}
My biggest concern is how to align the "ns". I'm less concerned with the
0.5 being formatted decimal aligned.

No comments:

Post a Comment