Skip to content

Improve performance of fmt::format on integer formatting #193

Closed
@vitaut

Description

@vitaut

Current results:

['Method'                      , 'Time, s' , 'Time ratio' ],
['fmt::FormatInt'              ,   0.130366,           1.0],
['fmt::Writer'                 ,    0.15293, 1.17308193854],
['cppx::decimal_from'          ,   0.158245, 1.21385177117],
['karma::generate'             ,   0.163913, 1.25732936502],
['karma::generate+std::string' ,   0.317622, 2.43638678797],
['fmt::Writer+std::string'     ,   0.327253, 2.51026341224],
['ltoa'                        ,   0.489808, 3.75717595078],
['itostr'                      ,   0.615213,  4.7191215501],
['sprintf'                     ,   0.883171, 6.77455011276],
['fmt::format'                 ,   0.956393, 7.33621496402], <---
['boost::lexical_cast'         ,   0.994558, 7.62896767562],
['sprintf+std::string'         ,    1.02793, 7.88495466609],
['std::to_string'              ,    1.34569, 10.3224000123],
['std::stringstream'           ,    1.38597, 10.6313762791],
['boost::format'               ,    4.07773, 31.2790911741]

For comparison, here are results from 1b80148:

['Method'                      , 'Time, s' , 'Time ratio' ],
['fmt::FormatInt'              ,   0.141162,           1.0],
['karma::generate'             ,   0.162126,  1.1485102223],
['cppx::decimal_from'          ,   0.167754, 1.18837930888],
['fmt::Writer'                 ,   0.192687, 1.36500616313],
['karma::generate+std::string' ,   0.321725, 2.27911902637],
['fmt::Writer+std::string'     ,   0.387114, 2.74233858971],
['fmt::format'                 ,   0.462457,  3.2760728808], <---
['ltoa'                        ,   0.487219, 3.45148836089],
['itostr'                      ,   0.665112, 4.71169294853],
['sprintf'                     ,   0.894235, 6.33481390176],
['boost::lexical_cast'         ,    1.04254, 7.38541533841],
['sprintf+std::string'         ,    1.04865, 7.42869894164],
['std::stringstream'           ,    1.27094, 9.00341451665],
['std::to_string'              ,    1.34653, 9.53889857044],
['boost::format'               ,    4.40832, 31.2288009521]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions