Giter Club home page Giter Club logo

Comments (2)

vitaut avatar vitaut commented on May 18, 2024

Thanks for your comments.

The results for the int-generator benchmark, which BTW is taken from Karma, that you give are similar to the ones I reported in http://zverovich.net/2013/09/07/integer-to-string-conversion-in-cplusplus.html .

Boost Karma is indeed pretty fast, but unfortunately it doesn't support replacement-based formatting. So it is not surprising that it is faster than fmt::Format which in addition to formatting also performs parsing of a format string and handling of positional arguments. Therefore it make more sense comparing Karma to fmt::Writer rather than to fmt::Format.

As you can see fmt::Writer is slightly faster than karma::generate on the original benchmark although it does automatic buffer management while Karma uses a fixed buffer. I'll have a look why allocating additional std::string causes larger performance impact with fmt::Writer than with Karma, but the main point is that with fmt::Writer you usually don't need this allocation, because the buffer management is automatic.

fmt::FormatInt works with int64_t now.

As for the modified benchmark, as far as I understand it compares the performance of formatting of single-digit and double-digit numbers. Since formatting of such small numbers is very fast, the buffer management that fmt::Writer does becomes a significant factor. Karma on the other hand offloads the buffer management to the user. Anyway, even for small inputs fmt::FormatInt is somewhat faster than karma::generate:

% 10 results:
karma::generate: 0.0991358 [s]
fmt::FormatInt: 0.0979277 [s]

% 100 results:
karma::generate: 0.0997507 [s]
fmt::FormatInt: 0.0943652 [s]

from fmt.

vitaut avatar vitaut commented on May 18, 2024

BTW where is this library page that you've mentioned?

from fmt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.