Commit a7f68dcc authored by Victor Zverovich's avatar Victor Zverovich

Update readme

parent 1428b342
...@@ -248,17 +248,17 @@ libraries. The reason for creating a new library is that every existing ...@@ -248,17 +248,17 @@ libraries. The reason for creating a new library is that every existing
solution that I found either had serious issues or didn't provide solution that I found either had serious issues or didn't provide
all the features I needed. all the features I needed.
Printf printf
~~~~~~ ~~~~~~
The good thing about printf is that it is pretty fast and readily available The good thing about ``printf`` is that it is pretty fast and readily available
being a part of the C standard library. The main drawback is that it being a part of the C standard library. The main drawback is that it
doesn't support user-defined types. Printf also has safety issues although doesn't support user-defined types. ``print`` also has safety issues although
they are mostly solved with `__attribute__ ((format (printf, ...)) they are somewhat mitigated with `__attribute__ ((format (printf, ...))
<http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html>`_ in GCC. <http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html>`_ in GCC.
There is a POSIX extension that adds positional arguments required for There is a POSIX extension that adds positional arguments required for
`i18n <https://en.wikipedia.org/wiki/Internationalization_and_localization>`_ `i18n <https://en.wikipedia.org/wiki/Internationalization_and_localization>`_
to printf but it is not a part of C99 and may not be available on some to ``printf`` but it is not a part of C99 and may not be available on some
platforms. platforms.
iostreams iostreams
...@@ -280,16 +280,16 @@ Matthew Wilson, the author of FastFormat, called this "chevron hell". iostreams ...@@ -280,16 +280,16 @@ Matthew Wilson, the author of FastFormat, called this "chevron hell". iostreams
don't support positional arguments by design. don't support positional arguments by design.
The good part is that iostreams support user-defined types and are safe although The good part is that iostreams support user-defined types and are safe although
error reporting is awkward. error handling is awkward.
Boost Format library Boost Format
~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~
This is a very powerful library which supports both printf-like format This is a very powerful library which supports both ``printf``-like format
strings and positional arguments. Its main drawback is performance. strings and positional arguments. Its main drawback is performance. According to
According to various benchmarks it is much slower than other methods various benchmarks it is much slower than other methods considered here. Boost
considered here. Boost Format also has excessive build times and severe Format also has excessive build times and severe code bloat issues (see
code bloat issues (see `Benchmarks`_). `Benchmarks`_).
FastFormat FastFormat
~~~~~~~~~~ ~~~~~~~~~~
...@@ -310,26 +310,24 @@ too restrictive for using it in some projects. ...@@ -310,26 +310,24 @@ too restrictive for using it in some projects.
Loki SafeFormat Loki SafeFormat
~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~
SafeFormat is a formatting library which uses printf-like format strings SafeFormat is a formatting library which uses ``printf``-like format strings and
and is type safe. It doesn't support user-defined types or positional is type safe. It doesn't support user-defined types or positional arguments and
arguments. It makes unconventional use of ``operator()`` for passing makes unconventional use of ``operator()`` for passing format arguments.
format arguments.
Tinyformat Tinyformat
~~~~~~~~~~ ~~~~~~~~~~
This library supports printf-like format strings and is very small and This library supports ``printf``-like format strings and is very small .
fast. Unfortunately it doesn't support positional arguments and wrapping It doesn't support positional arguments and wrapping it in C++98 is somewhat
it in C++98 is somewhat difficult. Also its performance and code compactness difficult. Tinyformat relies on iostreams which limits its performance.
are limited by iostreams.
Boost Spirit.Karma Boost Spirit.Karma
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
This is not really a formatting library but I decided to include it here This is not really a formatting library but I decided to include it here for
for completeness. As iostreams it suffers from the problem of mixing completeness. As iostreams, it suffers from the problem of mixing verbatim text
verbatim text with arguments. The library is pretty fast, but slower with arguments. The library is pretty fast, but slower on integer formatting
on integer formatting than ``fmt::Writer`` on Karma's own benchmark, than ``fmt::format_int`` on Karma's own benchmark,
see `Fast integer to string conversion in C++ see `Fast integer to string conversion in C++
<http://zverovich.net/2013/09/07/integer-to-string-conversion-in-cplusplus.html>`_. <http://zverovich.net/2013/09/07/integer-to-string-conversion-in-cplusplus.html>`_.
...@@ -350,13 +348,13 @@ Boost Format 1.67 boost::format 7.98 ...@@ -350,13 +348,13 @@ Boost Format 1.67 boost::format 7.98
Folly Format folly::format 2.23 Folly Format folly::format 2.23
================= ============= =========== ================= ============= ===========
{fmt} is the fastest of the benchmarked methods, ~17% faster than `printf`. {fmt} is the fastest of the benchmarked methods, ~17% faster than ``printf``.
The above results were generated by building ``tinyformat_test.cpp`` on macOS The above results were generated by building ``tinyformat_test.cpp`` on macOS
10.14.3 with ``clang++ -O3 -DSPEED_TEST -DHAVE_FORMAT``, and taking the best of 10.14.3 with ``clang++ -O3 -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"`` three runs. In the test, the format string ``"%0.10f:%04d:%+g:%s:%p:%c:%%\n"``
or equivalent is filled 2000000 times with output sent to ``/dev/null``; for or equivalent is filled 2,000,000 times with output sent to ``/dev/null``; for
further details see the `source further details refer to the `source
<https://github.com/fmtlib/format-benchmark/blob/master/tinyformat_test.cpp>`_. <https://github.com/fmtlib/format-benchmark/blob/master/tinyformat_test.cpp>`_.
Compile time and code bloat Compile time and code bloat
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment