mirror of
https://github.com/fmtlib/fmt.git
synced 2026-09-13 14:22:26 +08:00
Simplify performance overview
This commit is contained in:
parent
8bd6079278
commit
ba24da597a
38
README.md
38
README.md
@ -180,35 +180,25 @@ Output on a modern terminal with Unicode support:
|
||||
|
||||

|
||||
|
||||
# Benchmarks
|
||||
# Performance
|
||||
|
||||
## Speed tests
|
||||
{fmt} can be tens of percent to 20–30 times faster than iostreams and
|
||||
`sprintf`, especially for numeric formatting. It minimizes dynamic memory
|
||||
allocations and can optionally [compile format strings](
|
||||
https://fmt.dev/latest/api/#compile-api) into efficient formatting code.
|
||||
|
||||
| Library | Method | Run Time, s |
|
||||
|-------------------|---------------|-------------|
|
||||
| libc | printf | 0.66 |
|
||||
| libc++ | std::ostream | 1.63 |
|
||||
| {fmt} 12.1 | fmt::print | 0.44 |
|
||||
| Boost Format 1.88 | boost::format | 3.89 |
|
||||
| Folly Format | folly::format | 1.28 |
|
||||
See [format-benchmark](https://github.com/fmtlib/format-benchmark) and
|
||||
[dtoa-benchmark](https://github.com/fmtlib/dtoa-benchmark) for benchmarks
|
||||
and methodology.
|
||||
|
||||
{fmt} is the fastest of the benchmarked methods, \~50% faster than
|
||||
`printf`.
|
||||
**Time per double (smaller is better):**
|
||||
|
||||
The above results were generated by building `tinyformat_test.cpp` on
|
||||
macOS 15.6.1 with `clang++ -O3 -DNDEBUG -DSPEED_TEST -DHAVE_FORMAT`, and
|
||||
taking the best of three runs. In the test, the format string
|
||||
`"%0.10f:%04d:%+g:%s:%p:%c:%%\n"` or equivalent is filled 2,000,000
|
||||
times with output sent to `/dev/null`; for further details refer to the
|
||||
[source](https://github.com/fmtlib/format-benchmark/blob/master/src/tinyformat-test.cc).
|
||||
[](
|
||||
https://github.com/fmtlib/dtoa-benchmark)
|
||||
|
||||
{fmt} is up to 20-30x faster than `std::ostringstream` and `sprintf` on
|
||||
IEEE754 `float` and `double` formatting
|
||||
([dtoa-benchmark](https://github.com/fmtlib/dtoa-benchmark)) and faster
|
||||
than [double-conversion](https://github.com/google/double-conversion)
|
||||
and [ryu](https://github.com/ulfjack/ryu):
|
||||
|
||||
[](https://fmt.dev/unknown_mac64_clang12.0.html)
|
||||
`ostringstream` and `sprintf` are omitted because they are an order of
|
||||
magnitude slower than the other methods.
|
||||
|
||||
## Compile time and code bloat
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user