Performance numbers on different scales

Software profilers, memory data sheets and storage benchmarks report time on very different scales. A function call may take 50 ns, a flash read 100,000 ns and a hard disk seek 8 ms, and these appear in the same article or the same tuning session. This page multiplies the millisecond value by 1,000,000 and gives nanoseconds, so that every number is in one unit. Developers, system administrators and computer science students use it to compare numbers from a profiler with figures from a hardware manual. The figures are large, and the page prints them in full so that you can count the digits.

Six decimal places between the prefixes

Milli stands for 10^-3 and nano for 10^-9, so a millisecond contains 10^6 nanoseconds, a million. The second is the SI base unit, and the BIPM SI Brochure and NIST SP 811 list both prefixes. The factor is defined and has no uncertainty. A check through microseconds is easy: multiply by 1,000 to get µs, then by 1,000 again to get ns. Both routes must agree. In code, durations in nanoseconds are common because timer functions such as the monotonic clocks in many languages return them, and a program that mixes them with millisecond settings must convert with care. A common bug is passing a value in milliseconds to a function that expects nanoseconds, which makes the delay a million times too short.

Ten milliseconds in nanoseconds

With the default of 10 ms the page returns 10,000,000 ns. Other values: 0.5 ms is 500,000 ns, 2.5 ms is 2,500,000 ns and 0.001 ms is 1,000 ns. The result is always a million times the input. If it is smaller than the input, the menus are reversed. Seven digits are easy to misread, so group them in threes as in 10,000,000. Spreadsheet formats that show thousands separators make this easy. A value of 10 ms is also 0.01 s, and a program that sleeps for 10 ms will not wake up with nanosecond precision, since operating system schedulers typically add jitter of tens or hundreds of microseconds.

Frame times in games and video

A display refreshing 60 times per second shows a new frame every 16.67 ms, which is about 16,666,667 ns. A 144 Hz monitor has a frame time of 6.944 ms, about 6,944,444 ns. A game that needs to finish its work inside the frame must keep the sum of its tasks below that budget. Profilers report each task in microseconds or nanoseconds, and the page makes it easy to see how much of the budget a task uses: a task of 2,000,000 ns takes 2 ms, one eighth of a 60 Hz frame. A task of 500,000 ns is 0.5 ms, about 3 percent of the frame. These numbers describe the arithmetic of frame budgets, not the performance of any particular game or device. Frame pacing also depends on the display, the driver and the engine, so the budget is a starting point for analysis.

Storage and memory latency

Typical orders of magnitude help in judging a figure. A DRAM access takes on the order of 100 ns. A read from a solid-state drive takes tens to hundreds of microseconds, for example 100 µs, which is 0.1 ms or 100,000 ns. A seek on a spinning hard disk takes several milliseconds, say 8 ms, which is 8,000,000 ns. A network round trip inside a data center may take 0.5 ms, or 500,000 ns. Individual devices vary and these figures are illustrative, so check the data sheet of the device you use. Vendors often list typical and worst-case values, and the gap between them can be large. The spread of five orders of magnitude between memory and disk explains why caching matters so much in software.

Processor clock periods

A processor running at 3 GHz completes a clock cycle every 0.3333 ns. In a millisecond it runs 3,000,000 cycles. A task of 10 ms spans 30,000,000 cycles at that speed, which is a rough guide to how much work fits in that time, since modern processors execute several instructions per cycle and also wait for memory. The page does not use the clock rate and converts only time units, but the numbers show why nanoseconds are the natural unit for processor and memory timing and milliseconds the natural unit for user interface response and disk access. Cache hits and misses change the picture again, so a measured time on your own machine is worth more than a cycle count.

From nanoseconds back to milliseconds

Choose nanoseconds as the source and milliseconds as the target. The page divides by 1,000,000. A value of 250,000 ns is 0.25 ms, 1,000,000 ns is 1 ms and 8,000,000 ns is 8 ms. Profiler output often lists many nanosecond values with long digit strings, and converting the total to milliseconds gives a number that is easy to compare with a user interface budget of, say, 16 ms. Keep the original nanosecond values in the data and convert only for the summary, so no precision is lost in the raw record. A tool that stores durations as 64-bit integers in nanoseconds can hold about 292 years, so there is no overflow concern at this scale.

Reading profiler output

Profilers and benchmark tools print results in a mix of units: total run time in milliseconds, per-call time in microseconds and counters in nanoseconds. A function that takes 850 ns per call and is called 12,000 times in a request adds up to 10,200,000 ns, which is 10.2 ms. That sum, not the single call time, decides whether the request meets a 20 ms budget. Converting everything to nanoseconds before adding avoids mistakes with prefixes, and converting the total back to milliseconds gives a figure that fits the budget. Keep the raw data in nanoseconds and do the conversion at the end for the summary.

Profilers, clocks and the nanosecond figure

The page changes a unit of time. It does not measure performance, judge whether a latency is acceptable or tell you how accurate a timer is. Clock resolution and jitter depend on the hardware and the operating system, and a timer that reports nanoseconds may only update every few tens of nanoseconds or more. Use the documentation of your platform and your own measurements for decisions.