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

Faster parsing of hex and decimal represented big numbers #781

Open
plokhotnyuk opened this issue Mar 18, 2019 · 0 comments
Open

Faster parsing of hex and decimal represented big numbers #781

plokhotnyuk opened this issue Mar 18, 2019 · 0 comments

Comments

@plokhotnyuk
Copy link

plokhotnyuk commented Mar 18, 2019

Default constructors of BigInt (and BigDecimal) from the string representation have O(n^2) complexity, while for power of 2 bases (like 16) and for others (like 10) corresponding complexities can be archived: O(n) and O(n^1.5).

scala> def timed[A](f: => A): A = { val t = System.currentTimeMillis; val r = f; println(s"Elapsed time: ${System.currentTimeMillis - t}"); r }
timed: [A](f: => A)A

scala> timed(BigInt("9" * 10000))
Elapsed time: 2

scala> timed(BigInt("9" * 100000))
Elapsed time: 131

scala> timed(BigInt("9" * 1000000))
Elapsed time: 13204

scala> timed(BigInt("F" * 10000, 16))
Elapsed time: 2

scala> timed(BigInt("F" * 100000, 16))
Elapsed time: 210

scala> timed(BigInt("F" * 1000000, 16))
Elapsed time: 20356

Does spire have more efficient constructors from string representations?

JoeWrightss pushed a commit to JoeWrightss/spire that referenced this issue Apr 13, 2019
Update k8s examples README to include PSAT attestor
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