[squeak-dev] Fun with spock (NativeBoost FFI)

Nicolas Cellier nicolas.cellier.aka.nice at gmail.com
Sun May 13 20:34:47 UTC 2012


2012/5/13 Igor Stasenko <siguctua at gmail.com>:
> On 13 May 2012 20:58, Nicolas Cellier
> <nicolas.cellier.aka.nice at gmail.com> wrote:
>> Smalltalk cannot beat gmp, but the comparison is not fair, anything
>> can beat current implementation of factorial...
>
> Right. It is not fair. Especially that we're talking about something
> implemented in C
> vs something implemented in smalltalk.
> The comparison would be more fair if we could have a separate
> primitive for factorial.
>

[100000 primeSwingFactorial] timeToRun 3411
[100000 factorial] timeToRun 61219

So gmp is still 40x faster than a reasonably optimized Smalltalk factorial...
I think that's fair, because gmp is highly optimized.

Since cost is dominated by LargeInteger arithmetic, and since
Smalltalk LargeInteger arithmetic in primitives still operates on
bytes, I'm not so surprised of the gap...

I'd like to see a 64bit image operating on 32 bits positive integers
digits, that would already be a progress...

Nicolas

>> See http://smallissimo.blogspot.fr/2011/07/evaluating-factorial-from-its-prime.html
>> and some following posts which has a few links on how to compute it
>> efficiently.
>>
>> Nicolas
>>
>> 2012/5/13 Lawson English <lenglish5 at cox.net>:
>>> On 5/13/12 11:02 AM, Lawson English wrote:
>>>
>>> [results]
>>>
>>> Ack, I printed the times for the gmplib off by a factor of 10. However, the
>>> ratio is still correct.
>>>
>>> gmplib is at least 700x faster than the built-in factorial method for 100000
>>> factorial.
>>>
>>>
>>> --
>>> Squeak from the very start (introduction to Squeak and Pharo Smalltalk for
>>> the (almost) complete and compleate beginner).
>>> https://www.youtube.com/playlist?list=PL6601A198DF14788D&feature=view_all
>>>
>>>
>>
>
>
>
> --
> Best regards,
> Igor Stasenko.
>


More information about the Squeak-dev mailing list