Skip to content

Commit

Permalink
Update included fmt lib to 10.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
joto committed Nov 1, 2023
1 parent d80bbcb commit 2f0ec97
Show file tree
Hide file tree
Showing 18 changed files with 3,244 additions and 3,089 deletions.
2 changes: 1 addition & 1 deletion contrib/fmt/LICENSE.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2012 - present, Victor Zverovich
Copyright (c) 2012 - present, Victor Zverovich and {fmt} contributors

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand Down
2 changes: 1 addition & 1 deletion contrib/fmt/README.contrib
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Source: https://github.com/fmtlib/fmt
Revision: v9.1.0
Revision: v10.1.0
67 changes: 39 additions & 28 deletions contrib/fmt/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ Features
* `Format string syntax <https://fmt.dev/latest/syntax.html>`_ similar to Python's
`format <https://docs.python.org/3/library/stdtypes.html#str.format>`_
* Fast IEEE 754 floating-point formatter with correct rounding, shortness and
round-trip guarantees
round-trip guarantees using the `Dragonbox <https://github.com/jk-jeon/dragonbox>`_
algorithm
* Portable Unicode support
* Safe `printf implementation
<https://fmt.dev/latest/api.html#printf-formatting>`_ including the POSIX
extension for positional arguments
Expand All @@ -64,7 +66,7 @@ Features
<https://github.com/fmtlib/fmt/tree/master/test>`_ and is `continuously fuzzed
<https://bugs.chromium.org/p/oss-fuzz/issues/list?colspec=ID%20Type%20
Component%20Status%20Proj%20Reported%20Owner%20Summary&q=proj%3Dfmt&can=1>`_
* Safety: the library is fully type safe, errors in format strings can be
* Safety: the library is fully type-safe, errors in format strings can be
reported at compile time, automatic memory management prevents buffer overflow
errors
* Ease of use: small self-contained code base, no external dependencies,
Expand All @@ -74,7 +76,7 @@ Features
consistent output across platforms and support for older compilers
* Clean warning-free codebase even on high warning levels such as
``-Wall -Wextra -pedantic``
* Locale-independence by default
* Locale independence by default
* Optional header-only configuration enabled with the ``FMT_HEADER_ONLY`` macro

See the `documentation <https://fmt.dev>`_ for more details.
Expand Down Expand Up @@ -191,24 +193,24 @@ Speed tests
================= ============= ===========
Library Method Run Time, s
================= ============= ===========
libc printf 1.04
libc++ std::ostream 3.05
{fmt} 6.1.1 fmt::print 0.75
Boost Format 1.67 boost::format 7.24
Folly Format folly::format 2.23
libc printf 0.91
libc++ std::ostream 2.49
{fmt} 9.1 fmt::print 0.74
Boost Format 1.80 boost::format 6.26
Folly Format folly::format 1.87
================= ============= ===========

{fmt} is the fastest of the benchmarked methods, ~35% faster than ``printf``.
{fmt} is the fastest of the benchmarked methods, ~20% faster than ``printf``.

The above results were generated by building ``tinyformat_test.cpp`` on macOS
10.14.6 with ``clang++ -O3 -DNDEBUG -DSPEED_TEST -DHAVE_FORMAT``, and taking the
12.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>`_.

{fmt} is up to 20-30x faster than ``std::ostringstream`` and ``sprintf`` on
floating-point formatting (`dtoa-benchmark <https://github.com/fmtlib/dtoa-benchmark>`_)
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>`_:

Expand All @@ -224,7 +226,7 @@ The script `bloat-test.py
from `format-benchmark <https://github.com/fmtlib/format-benchmark>`_
tests compile time and code bloat for nontrivial projects.
It generates 100 translation units and uses ``printf()`` or its alternative
five times in each to simulate a medium sized project. The resulting
five times in each to simulate a medium-sized project. The resulting
executable size and compile time (Apple LLVM version 8.1.0 (clang-802.0.42),
macOS Sierra, best of three) is shown in the following tables.

Expand All @@ -245,7 +247,7 @@ As you can see, {fmt} has 60% less overhead in terms of resulting binary code
size compared to iostreams and comes pretty close to ``printf``. Boost Format
and Folly Format have the largest overheads.

``printf+string`` is the same as ``printf`` but with extra ``<string>``
``printf+string`` is the same as ``printf`` but with an extra ``<string>``
include to measure the overhead of the latter.

**Non-optimized build**
Expand All @@ -261,14 +263,14 @@ Boost Format 54.1 365 303
Folly Format 79.9 445 430
============= =============== ==================== ==================

``libc``, ``lib(std)c++`` and ``libfmt`` are all linked as shared libraries to
``libc``, ``lib(std)c++``, and ``libfmt`` are all linked as shared libraries to
compare formatting function overhead only. Boost Format is a
header-only library so it doesn't provide any linkage options.

Running the tests
~~~~~~~~~~~~~~~~~

Please refer to `Building the library`__ for the instructions on how to build
Please refer to `Building the library`__ for instructions on how to build
the library and run the unit tests.

__ https://fmt.dev/latest/usage.html#building-the-library
Expand All @@ -293,18 +295,19 @@ or the bloat test::
Migrating code
--------------

`clang-tidy-fmt <https://github.com/mikecrowe/clang-tidy-fmt>`_ provides clang
tidy checks for converting occurrences of ``printf`` and ``fprintf`` to
``fmt::print``.
`clang-tidy <https://clang.llvm.org/extra/clang-tidy/>`_ v17 (not yet
released) provides the `modernize-use-std-print
<https://clang.llvm.org/extra/clang-tidy/checks/modernize/use-std-print.html>`_
check that is capable of converting occurrences of ``printf`` and
``fprintf`` to ``fmt::print`` if configured to do so. (By default it
converts to ``std::print``.)

Projects using this library
---------------------------

* `0 A.D. <https://play0ad.com/>`_: a free, open-source, cross-platform
real-time strategy game

* `2GIS <https://2gis.ru/>`_: free business listings with a city map

* `AMPL/MP <https://github.com/ampl/mp>`_:
an open-source library for mathematical programming

Expand All @@ -322,8 +325,10 @@ Projects using this library

* `ccache <https://ccache.dev/>`_: a compiler cache

* `ClickHouse <https://github.com/ClickHouse/ClickHouse>`_: analytical database
* `ClickHouse <https://github.com/ClickHouse/ClickHouse>`_: an analytical database
management system

* `Contour <https://github.com/contour-terminal/contour/>`_: a modern terminal emulator

* `CUAUV <https://cuauv.org/>`_: Cornell University's autonomous underwater
vehicle
Expand Down Expand Up @@ -360,6 +365,10 @@ Projects using this library

* `Knuth <https://kth.cash/>`_: high-performance Bitcoin full-node

* `libunicode <https://github.com/contour-terminal/libunicode/>`_: a modern C++17 Unicode library

* `MariaDB <https://mariadb.org/>`_: relational database management system

* `Microsoft Verona <https://github.com/microsoft/verona>`_:
research programming language for concurrent ownership

Expand Down Expand Up @@ -389,7 +398,7 @@ Projects using this library
proxy

* `redpanda <https://vectorized.io/redpanda>`_: a 10x faster Kafka® replacement
for mission critical systems written in C++
for mission-critical systems written in C++

* `rpclib <http://rpclib.net/>`_: a modern C++ msgpack-RPC server and client
library
Expand All @@ -413,6 +422,9 @@ Projects using this library
* `TrinityCore <https://github.com/TrinityCore/TrinityCore>`_: open-source
MMORPG framework

* `🐙 userver framework <https://userver.tech/>`_: open-source asynchronous
framework with a rich set of abstractions and database drivers

* `Windows Terminal <https://github.com/microsoft/terminal>`_: the new Windows
terminal

Expand Down Expand Up @@ -470,7 +482,7 @@ error handling is awkward.
Boost Format
~~~~~~~~~~~~

This is a very powerful library which supports both ``printf``-like format
This is a very powerful library that supports both ``printf``-like format
strings and positional arguments. Its main drawback is performance. According to
various benchmarks, it is much slower than other methods considered here. Boost
Format also has excessive build times and severe code bloat issues (see
Expand All @@ -479,7 +491,7 @@ Format also has excessive build times and severe code bloat issues (see
FastFormat
~~~~~~~~~~

This is an interesting library which is fast, safe and has positional arguments.
This is an interesting library that is fast, safe, and has positional arguments.
However, it has significant limitations, citing its author:

Three features that have no hope of being accommodated within the
Expand All @@ -495,7 +507,7 @@ restrictive for using it in some projects.
Boost Spirit.Karma
~~~~~~~~~~~~~~~~~~

This is not really a formatting library but I decided to include it here for
This is not a formatting library but I decided to include it here for
completeness. As iostreams, it suffers from the problem of mixing verbatim text
with arguments. The library is pretty fast, but slower on integer formatting
than ``fmt::format_to`` with format string compilation on Karma's own benchmark,
Expand All @@ -514,7 +526,7 @@ Documentation License
The `Format String Syntax <https://fmt.dev/latest/syntax.html>`_
section in the documentation is based on the one from Python `string module
documentation <https://docs.python.org/3/library/string.html#module-string>`_.
For this reason the documentation is distributed under the Python Software
For this reason, the documentation is distributed under the Python Software
Foundation license available in `doc/python-license.txt
<https://raw.github.com/fmtlib/fmt/master/doc/python-license.txt>`_.
It only applies if you distribute the documentation of {fmt}.
Expand All @@ -523,8 +535,7 @@ Maintainers
-----------

The {fmt} library is maintained by Victor Zverovich (`vitaut
<https://github.com/vitaut>`_) and Jonathan Müller (`foonathan
<https://github.com/foonathan>`_) with contributions from many other people.
<https://github.com/vitaut>`_) with contributions from many other people.
See `Contributors <https://github.com/fmtlib/fmt/graphs/contributors>`_ and
`Releases <https://github.com/fmtlib/fmt/releases>`_ for some of the names.
Let us know if your contribution is not listed or mentioned incorrectly and
Expand Down
2 changes: 1 addition & 1 deletion contrib/fmt/include/fmt/args.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Formatting library for C++ - dynamic format arguments
// Formatting library for C++ - dynamic argument lists
//
// Copyright (c) 2012 - present, Victor Zverovich
// All rights reserved.
Expand Down
Loading

0 comments on commit 2f0ec97

Please sign in to comment.