M
Matt Mower
Hi folks.
Thanks to H. Yamamoto I am now able to profile my ART-2 implementation
which I perceive to be running slowly (although i've no competing
implementations to compare it with... maybe it's really greased weasel
fast...?)
The profiler shows the bad boys are:
% cumulative self self total
time seconds seconds calls ms/call ms/call name
33.99 9.92 9.92 37772 0.26 0.26 Kernel.callcc
12.69 13.62 3.70 6118 0.61 9.94 Generator#next
10.91 16.81 3.18 12768 0.25 4.79 Generator#end?
9.97 19.72 2.91 6118 0.48 1.67 Generator#yield
8.68 22.25 2.53 3345 0.76 16.39 Array#map
6.84 24.24 2.00 266 7.50 200.63 Proc#call
Overall runtime is about 30s and everything else is, individually,
less than 2% of run-time. As you can see I'm making use of the
SyncEnumerator from generator.rb. In particular I calculate the
Euclidean distance of two vectors (and I do this a lot) as:
def euclidean_distance( vector )
Math.sqrt( SyncEnumerator.new( self, vector ).collect { |i,j| (
i-j ) ** 2 }.inject( 0 ) { |s,v| s+v } )
end
Because SyncEnumerator cleverly offers me a full Enumerable I was able
to use #collect to calculate the squares to be passed to #inject for
summation. I find this good.
However I'm now wondering if the magic which makes SyncEnumerator work
is of the expensive kind (I'm assuming this is where all the Kernel#cc
calls are coming from as well).
Does anyone have any experience they can share about SyncEnumerator performance?
Regards,
Matt
Thanks to H. Yamamoto I am now able to profile my ART-2 implementation
which I perceive to be running slowly (although i've no competing
implementations to compare it with... maybe it's really greased weasel
fast...?)
The profiler shows the bad boys are:
% cumulative self self total
time seconds seconds calls ms/call ms/call name
33.99 9.92 9.92 37772 0.26 0.26 Kernel.callcc
12.69 13.62 3.70 6118 0.61 9.94 Generator#next
10.91 16.81 3.18 12768 0.25 4.79 Generator#end?
9.97 19.72 2.91 6118 0.48 1.67 Generator#yield
8.68 22.25 2.53 3345 0.76 16.39 Array#map
6.84 24.24 2.00 266 7.50 200.63 Proc#call
Overall runtime is about 30s and everything else is, individually,
less than 2% of run-time. As you can see I'm making use of the
SyncEnumerator from generator.rb. In particular I calculate the
Euclidean distance of two vectors (and I do this a lot) as:
def euclidean_distance( vector )
Math.sqrt( SyncEnumerator.new( self, vector ).collect { |i,j| (
i-j ) ** 2 }.inject( 0 ) { |s,v| s+v } )
end
Because SyncEnumerator cleverly offers me a full Enumerable I was able
to use #collect to calculate the squares to be passed to #inject for
summation. I find this good.
However I'm now wondering if the magic which makes SyncEnumerator work
is of the expensive kind (I'm assuming this is where all the Kernel#cc
calls are coming from as well).
Does anyone have any experience they can share about SyncEnumerator performance?
Regards,
Matt