Hardware datasheets and benchmark output

Memory modules, processors, network cards and microcontrollers specify their timing in nanoseconds, and benchmark tools print per-operation costs in the same unit. A programmer who measures a loop in seconds and compares it with a datasheet value in nanoseconds needs a conversion that does not slip by a power of ten. This page multiplies the seconds value by one billion and returns nanoseconds. The selector also offers microseconds, milliseconds, minutes, hours, days and weeks. The default of 10 s gives 10,000,000,000 ns, a number with eleven digits that shows how small the nanosecond is.

Nine places to the right

Nano is 10^-9 in the SI prefixes, so one second equals 1,000,000,000 ns and the formula is ns = s × 1,000,000,000. By hand, move the decimal point nine places to the right: 0.0001 s becomes 100,000 ns, 0.00000025 s becomes 250 ns and 0.000005 s becomes 5,000 ns. Going back, move the point nine places left. A minute holds 60 × 10^9 ns, which is 60,000,000,000, and an hour 3.6 × 10^12 ns. The relation is exact, and the main risk is a miscount of zeros, which grouped digits help to avoid.

Ten seconds as ten billion nanoseconds

At the default of 10 s the page returns 10,000,000,000 ns. A ten-digit figure is hard to read at a glance, so write it with separators or in scientific notation as 1 × 10^10 ns. It also shows why nanoseconds are not meant for spans of seconds: in practice you would use them for events inside a processor or on a wire. If you find yourself reading results with more than about nine digits, a coarser unit such as microseconds or milliseconds will make the report easier to scan without losing information.

Clock periods of processors

A processor clock at 3 GHz ticks every 0.333 ns, a 100 MHz bus every 10 ns and a 1 GHz signal every 1 ns. Converting a period from seconds, 3.333 × 10^-10 s, to nanoseconds gives 0.3333 ns. Memory timings such as access latency are specified in nanoseconds on datasheets, and actual round trips to main memory take tens of nanoseconds up to about a hundred, depending on the system. Those figures are illustrations of scale, and the exact numbers belong to the hardware. The page changes the unit of whatever period you enter and gives no judgment on performance. Going the other way, a period of 2 ns corresponds to a frequency of 500 MHz, since the frequency is the reciprocal of the period, and that reciprocal is a calculation for a separate page.

Signals in cables and fiber

Light in optical fiber travels at roughly two thirds of its speed in a vacuum, which works out to about 5 microseconds per kilometer, or 5,000 ns. A 100 km link therefore adds about 500 microseconds, or 500,000 ns, in one direction. Network engineers use such numbers for latency budgets, for trading links and for clock synchronization over fiber. Copper cable is similar in magnitude. The figures here are approximations that depend on the cable type, and a datasheet gives the propagation delay of a specific cable. The page keeps the units straight when you combine delays given in different scales. A switch that adds 800 ns, a cable of 20 m at about 5 ns per meter, which is 100 ns, and a network card that adds 1,500 ns give a one-way total of 2,400 ns, or 2.4 µs.

Per-operation costs in benchmarks

A benchmark that runs one million operations in 0.25 seconds reports 250 ns per operation, since 0.25 s is 250,000,000 ns and dividing by 1,000,000 gives 250. Converting the total first and dividing afterward keeps the arithmetic in integers. Many benchmark frameworks print results in ns per operation, and comparing two libraries means comparing those numbers. Another run of 2 million operations in 0.5 seconds is 500,000,000 ns, which gives the same 250 ns each. A difference of 20 ns on a result of 250 ns is an 8 percent change, which may or may not matter in a given program. Measurement noise from other processes affects the digits, so repeat runs before you act on a small gap. A tool that prints the best of several runs, the median or the mean answers three different questions, and the page converts the number whichever one it is.

From nanoseconds back to seconds

Choose nanoseconds as the source and seconds as the target to divide by one billion. A value of 250 ns equals 2.5 × 10^-7 s, 5,000 ns equals 5 × 10^-6 s and 1,500,000,000 ns equals 1.5 s. Results with such small numbers are best written in scientific notation, which the page uses when the value is below about one millionth. When you copy a small result into a spreadsheet, make sure the cell format shows scientific notation, otherwise it may display 0.000000 and hide the value completely, even though the stored number is correct.

Nanosecond timestamps and exact integers

Some systems return the current time in nanoseconds since the Unix epoch, a figure near 1.78 × 10^18. A double precision floating-point number holds integers exactly only up to about 9.007 × 10^15, so such a timestamp loses its last digits if it is stored as a double, as spreadsheets and some scripting languages do. For exact work, keep nanosecond timestamps as 64-bit integers or as text. The converter works on numbers of ordinary size and warns of nothing, so a Unix time of 1,780,000,000 s becomes 1.78 × 10^18 ns on the page, with digits at the end that a double cannot hold exactly. Treat the leading digits as meaningful and the trailing ones as unreliable. If you convert a Unix time in seconds into nanoseconds here, the last digits you see may not be exact, so do not use them for ordering events.

Nanosecond figures need a clock that can resolve them

Writing a duration in nanoseconds does not mean that any clock can measure it. Operating system timers, sampling intervals and the resolution of the hardware counter set the finest step you can observe, and many results include jitter larger than a nanosecond. The page applies a defined factor and returns the exact product of your input. How accurate the input was, and whether the measurement included setup or waiting time, comes from the tool that produced it. Report nanosecond figures with the number of digits the measurement supports.