Scala BigInt.pow performance

212 views
Skip to first unread message

Sarge M

unread,
Jun 15, 2012, 8:02:52 AM6/15/12
to scala-user
On some input, scala's BigInt.pow(Int):BigInt is slower than an
equivalent hand-written function. For example, look here:
http://ideone.com/HEpiz
In that example, the "pow" function runs for 1.252sec, and its
alternative for 1.188sec. (I have also tested it in a loop, timings
are stable, but ideone doesn't allow program to run more than 5 sec,
so there is short version)
However, at some other inputs the opposite things happen. So the
question is - how the "pow" function works, in a nutshell?

√iktor Ҡlang

unread,
Jun 15, 2012, 8:23:33 AM6/15/12
to Sarge M, scala-user
https://github.com/scala/scala/blob/v2.9.2/src/library/scala/math/BigInt.scala#L229


--
Viktor Klang

Akka Tech Lead
Typesafe - The software stack for applications that scale

Twitter: @viktorklang

Reply all
Reply to author
Forward
0 new messages