swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Swarm-Support] objective-c vs. java


From: Rick Riolo
Subject: Re: [Swarm-Support] objective-c vs. java
Date: Mon, 23 Feb 2004 16:43:02 -0500 (EST)

Below are some results using the two approaches below,
for ints (as shown) and doubles (as appropriately modified).
As expected, the total speedup for doubles is less than for ints,
but even for int's its only about 10% faster,
so its not a huge speedup.

- r


address@hidden TestFastMC]$ time ./tg --batch -DNA=1000000000 -Dcm=0
numAnts = 1000000000
calling int via func(dist, M(getIntegerSample): .........
real    1m36.497s
user    1m35.350s
sys     0m0.030s

address@hidden TestFastMC]$ time ./tg --batch -DNA=1000000000 -Dcm=1
numAnts = 1000000000
calling int via regular method sending:..................
real    1m50.240s
user    1m49.100s
sys     0m0.000s

address@hidden TestFastMC]$ time ./tg --batch -DNA=1000000000 -Dcm=2
numAnts = 1000000000
calling double via funcd(distd, M(getDoubleSample):.......
real    3m13.153s
user    3m9.960s
sys     0m0.070s

address@hidden TestFastMC]$ time ./tg --batch -DNA=1000000000 -Dcm=3
numAnts = 1000000000
calling double via regular method sending:...............
real    3m24.296s
user    3m23.030s
sys     0m0.020s



-- 
Rick Riolo                           address@hidden
Center for the Study of Complex Systems (CSCS)
4477 Randall Lab                
University of Michigan         Ann Arbor MI 48109-1120
Phone: 734 763 3323                  Fax: 734 763 9267
http://cscs.umich.edu/~rlr

On Mon, 23 Feb 2004, Marcus G. Daniels wrote:

> Date: Mon, 23 Feb 2004 11:53:27 -0700
> From: Marcus G. Daniels <address@hidden>
> Reply-To: address@hidden
> To: address@hidden
> Subject: Re: [Swarm-Support] objective-c vs. java
> 
> Steve Railsback wrote:
> 
> > what you mean by "dynamic method dispatch"? Do you just mean using 
> > more method calls than necessary, or using code where the method to be 
> > called is a variable? Or something else?
> 
> Bad things are things like [self getPos] in the middle of a loop, where 
> getPos just returns an instance variable.   The cost of looking up the 
> method to call is much more than the work done by the method.  In those 
> circumstances, you want to set things up like:
> 
> id <UniformIntegerDist> dist =
>     [UniformIntegerDist create: globalZone
>           setGenerator: randomGenerator
>           setIntegerMin: 0
>           setMax: 100];
> int (*func) (id obj, SEL sel) =
>   (int (*) (id obj, SEL sel)) [(id) dist methodFor: M(getIntegerSample)];
> 
> And call like:
> 
> for (i = 0; i < 1000000000; i++)  func(dist, M(getIntegerSample))
> 
> instead of:
> 
> for (i = 0 ; i < 1000000000; i++) [dist getIntegerSample];
> 
> Some methods take long enough to run that the cost of looking up their 
> code isn't a factor.   For example, the same code with doubles instead 
> of integers will spend most of the execution time computing the samples.
> _______________________________________________
> Support mailing list
> address@hidden
> http://www.swarm.org/mailman/listinfo/support
> 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]