mirror of
https://github.com/fmtlib/fmt.git
synced 2024-12-25 06:21:00 +00:00
Update readme.
This commit is contained in:
parent
659dd37b79
commit
58e53b4370
66
README.rst
66
README.rst
@ -8,6 +8,7 @@ Features
|
|||||||
|
|
||||||
* Format string syntax similar to the one used by `str.format
|
* Format string syntax similar to the one used by `str.format
|
||||||
<http://docs.python.org/2/library/stdtypes.html#str.format>`__ in Python.
|
<http://docs.python.org/2/library/stdtypes.html#str.format>`__ in Python.
|
||||||
|
* Support for user-defined types.
|
||||||
* High speed: performance of the current proof-of-concept implementation
|
* High speed: performance of the current proof-of-concept implementation
|
||||||
is close to that of iostreams (see `Speed tests`_).
|
is close to that of iostreams (see `Speed tests`_).
|
||||||
* Small code size both in terms of source code (format consists of a single
|
* Small code size both in terms of source code (format consists of a single
|
||||||
@ -15,12 +16,13 @@ Features
|
|||||||
(see `Compile time and code bloat`_).
|
(see `Compile time and code bloat`_).
|
||||||
* Easy deployment: small self-contained code base, no external dependencies,
|
* Easy deployment: small self-contained code base, no external dependencies,
|
||||||
permissive license.
|
permissive license.
|
||||||
* Support for user-defined types.
|
|
||||||
|
|
||||||
Example
|
Examples
|
||||||
-------
|
--------
|
||||||
|
|
||||||
fmt::Print("Hello, {0}!") << "world";
|
This prints "Hello, world!" to stdout:
|
||||||
|
|
||||||
|
fmt::Print("Hello, {0}!") << "world";
|
||||||
|
|
||||||
Benchmarks
|
Benchmarks
|
||||||
----------
|
----------
|
||||||
@ -28,6 +30,34 @@ Benchmarks
|
|||||||
Compile time and code bloat
|
Compile time and code bloat
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
Speed tests
|
||||||
|
~~~~~~~~~~~
|
||||||
|
|
||||||
|
The following speed tests results were generated by building
|
||||||
|
``tinyformat_test.cpp`` on Ubuntu GNU/Linux 12.10 with
|
||||||
|
``g++-4.7.2 -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"`` or
|
||||||
|
equivalent is filled 2000000 times with output sent to ``/dev/null``; for
|
||||||
|
further details see the `source
|
||||||
|
<https://github.com/vitaut/tinyformat/blob/master/tinyformat_test.cpp>`__.
|
||||||
|
|
||||||
|
============== ========
|
||||||
|
test name run time
|
||||||
|
============== ========
|
||||||
|
libc printf 1.26s
|
||||||
|
std::ostream 2.02s
|
||||||
|
format 2.20s
|
||||||
|
tinyformat 2.51s
|
||||||
|
boost::format 10.40s
|
||||||
|
============== ========
|
||||||
|
|
||||||
|
As you can see boost::format is much slower than the alternative methods; this
|
||||||
|
is confirmed by `other tests <http://accu.org/index.php/journals/1539>`__.
|
||||||
|
Tinyformat is quite good coming close to iostreams. Unfortunately tinyformat
|
||||||
|
cannot be faster than the iostreams because it uses them internally.
|
||||||
|
Performance of format is close to that of std::ostream but there is a room for
|
||||||
|
improvement since format is not based on iostreams.
|
||||||
|
|
||||||
The script ``bloat_test.sh`` from the `tinyformat
|
The script ``bloat_test.sh`` from the `tinyformat
|
||||||
<https://github.com/c42f/tinyformat>`__ repository tests compile time and
|
<https://github.com/c42f/tinyformat>`__ repository tests compile time and
|
||||||
code bloat for nontrivial projects. It generates 100 translation units
|
code bloat for nontrivial projects. It generates 100 translation units
|
||||||
@ -67,34 +97,6 @@ executable size is smaller with tinyformat then with format and for
|
|||||||
non-optimized build its the other way around. Boost::format has by far
|
non-optimized build its the other way around. Boost::format has by far
|
||||||
the largest overheads.
|
the largest overheads.
|
||||||
|
|
||||||
Speed tests
|
|
||||||
~~~~~~~~~~~
|
|
||||||
|
|
||||||
The following speed tests results were generated by building
|
|
||||||
``tinyformat_test.cpp`` on Ubuntu GNU/Linux 12.10 with
|
|
||||||
``g++-4.7.2 -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"`` or
|
|
||||||
equivalent is filled 2000000 times with output sent to ``/dev/null``; for
|
|
||||||
further details see the `source
|
|
||||||
<https://github.com/vitaut/tinyformat/blob/master/tinyformat_test.cpp>`__.
|
|
||||||
|
|
||||||
============== ========
|
|
||||||
test name run time
|
|
||||||
============== ========
|
|
||||||
libc printf 1.26s
|
|
||||||
std::ostream 2.02s
|
|
||||||
format 2.20s
|
|
||||||
tinyformat 2.51s
|
|
||||||
boost::format 10.40s
|
|
||||||
============== ========
|
|
||||||
|
|
||||||
As you can see boost::format is much slower than the alternative methods; this
|
|
||||||
is confirmed by `other tests <http://accu.org/index.php/journals/1539>`__.
|
|
||||||
Tinyformat is quite good coming close to iostreams. Unfortunately tinyformat
|
|
||||||
cannot be faster than the iostreams because it uses them internally.
|
|
||||||
Performance of format is close to that of std::ostream but there is a room for
|
|
||||||
improvement since format is not based on iostreams.
|
|
||||||
|
|
||||||
Running the tests
|
Running the tests
|
||||||
~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user