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 optimization to parsing of floating point numbers #59

Merged

Conversation

jlahd
Copy link
Contributor

@jlahd jlahd commented Jan 26, 2019

Parsing of floating point numbers was very slow, due to calling (expt 10) to scale the decimal part. This change uses a look-up table instead, falling back to calling expt only if there are more than 20 decimal digits in the input.

Test case:
(let ((s "{\"foo\":42.17,\"bar\":12.3456789012345}")) (time (dotimes (_ 1000000) (jonathan:parse s :as :alist))))

Before change, on CCL 1.11.5 (LinuxX8664): took 13,166,328 microseconds (13.166328 seconds) to run.
After change, on CCL: took 1,488,017 microseconds (1.488017 seconds) to run.

Before change, on SBCL 1.4.15: 1.757 seconds of real time
After change, on SBCL: 0.814 seconds of real time.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 71.186% when pulling 43a1f6a on jlahd:float-reading-optimization into 1f448b4 on Rudolph-Miller:master.

@rudolph-miller rudolph-miller merged commit cf24e4a into rudolph-miller:master Jan 28, 2019
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

Successfully merging this pull request may close these issues.

None yet

3 participants