Performance optimization to parsing of floating point numbers #59
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
.