Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance regression on integer formatting #186

Closed
vitaut opened this issue Jun 29, 2015 · 4 comments
Closed

Performance regression on integer formatting #186

vitaut opened this issue Jun 29, 2015 · 4 comments

Comments

@vitaut
Copy link
Contributor

vitaut commented Jun 29, 2015

fmt::format performance on integer formatting is down to sprintf level. Need to investigate and fix before 2.0.

['Method'                      , 'Time, s' , 'Time ratio' ],
['fmt::FormatInt'              ,   0.130368,           1.0],
['cppx::decimal_from'          ,   0.160879, 1.23403749386],
['karma::generate'             ,   0.163209, 1.25190997791],
['fmt::Writer'                 ,   0.201434, 1.54511843397],
['karma::generate+std::string' ,   0.319312, 2.44931271478],
['fmt::Writer+std::string'     ,   0.369383, 2.83338702749],
['ltoa'                        ,   0.487947, 3.74284333579],
['itostr'                      ,    0.62576,  4.7999509082],
['sprintf'                     ,   0.887256, 6.80578055965],
['boost::lexical_cast'         ,   0.952595, 7.30696950172],
['fmt::format'                 ,   0.995007,  7.6322947349],
['sprintf+std::string'         ,    1.04289, 7.99958578792],
['std::stringstream'           ,    1.25203, 9.60381381934],
['std::to_string'              ,    1.38192, 10.6001472754],
['boost::format'               ,    4.40774, 33.8099840452]
@vitaut
Copy link
Contributor Author

vitaut commented Jul 13, 2015

There was a minor performance regression in 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]

@vitaut
Copy link
Contributor Author

vitaut commented Aug 5, 2015

Improved in 922fe90:

['Method'                      , 'Time, s' , 'Time ratio' ],
['fmt::FormatInt'              ,   0.130876,           1.0],
['cppx::decimal_from'          ,   0.161449,  1.2336027996],
['karma::generate'             ,   0.161707, 1.23557413124],
['fmt::Writer'                 ,    0.17376, 1.32766893854], <---
['karma::generate+std::string' ,   0.319278, 2.43954582964],
['fmt::Writer+std::string'     ,   0.344104, 2.62923683487],
['ltoa'                        ,   0.487851, 3.72758183319],
['itostr'                      ,    0.61139, 4.67152113451],
['sprintf'                     ,   0.874873, 6.68474739448],
['boost::lexical_cast'         ,   0.924096, 7.06085149302],
['fmt::format'                 ,   0.992863, 7.58628778386],
['sprintf+std::string'         ,     1.0205,   7.797457135],
['std::stringstream'           ,    1.22714, 9.37635624561],
['std::to_string'              ,    1.31599, 10.0552431309],
['boost::format'               ,    4.20408, 32.1226198845]

@vitaut
Copy link
Contributor Author

vitaut commented Aug 5, 2015

As of 58fcf0c, integer formatting in fmt::Writer is back to normal (aka super fast):

['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]

@vitaut
Copy link
Contributor Author

vitaut commented Aug 5, 2015

This is fixed, but need to look into fmt::format: #193

@vitaut vitaut closed this as completed Aug 5, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant