Where can I find the world's fastest atof implementation?

前端 未结 6 707
南笙
南笙 2021-02-01 05:59

I\'m looking for an extremely fast atof() implementation on IA32 optimized for US-en locale, ASCII, and non-scientific notation. The windows multithreaded CRT falls down misera

6条回答
  •  孤独总比滥情好
    2021-02-01 06:35

    This implementation I just finished coding runs twice as fast as the built in 'atof' on my desktop. It converts 1024*1024*39 number inputs in 2 seconds, compared 4 seconds with my system's standard gnu 'atof'. (Including the setup time and getting memory and all that).

    UPDATE: Sorry I have to revoke my twice as fast claim. It's faster if the thing you're converting is already in a string, but if you're passing it hard coded string literals, it's about the same as atof. However I'm going to leave it here, as possibly with some tweaking of the ragel file and state machine, you may be able to generate faster code for specific purposes.

    https://github.com/matiu2/yajp

    The interesting files for you are:

    https://github.com/matiu2/yajp/blob/master/tests/test_number.cpp

    https://github.com/matiu2/yajp/blob/master/number.hpp

    Also you may be interested in the state machine that does the conversion:

提交回复
热议问题