Test what primitive is faster #clone, of #basicNew?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Test what primitive is faster #clone, of #basicNew?

Igor Stasenko
Hello,

creating a new objects is quite fast, but i wonder, what if it could
be made even faster
for objects of fixed size (not variable sized ones) by using a #clone
primitive instead of #basicNew?


The trick to use #clone is, that we can keep a 'sample' in class
instance variable:

Mytestclass class
        instanceVariableNames: 'sample'

Mytestclass class>>initialize
        sample := self basicNew

and then:

Mytestclass class>>new
        ^ sample clone initialize


The problem, that i can't make a benchmark , which could really tell
the difference between those two ways,
so we could be 100% sure what is faster.
Any ideas how to bench it?

--
Best regards,
Igor Stasenko AKA sig.

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project