# (no subject)

**URL:** <https://www.ruby-forum.com/t/no-subject/95231>\
**Category:** Ruby\
**Created:** [May 25, 2006, 1:43am UTC](https://www.ruby-forum.com/t/no-subject/95231 "2006-05-25T01:43:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Damir\_Azhar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e5b9ba/32.png) [@Damir\_Azhar](https://www.ruby-forum.com/u/Damir_Azhar)\
**Post date:** [May 25, 2006, 1:43am UTC](https://www.ruby-forum.com/t/no-subject/95231/1 "2006-05-25T01:43:57Z")

</div>

Hi,

I have been using the Ruby PCAP module to implement a simple network  
traffic  
flow meter based on the RTFM architecture. When I run my meter with the  
Ruby  
profiler option, I have discovered that the biggest single chunk of  
processing  
time goes to calls to the “each” function of the Range class, with calls  
to  
this method accounting for up to 23% of total processing time when the  
meter  
reads traffic data off trace files. This figure is approximately halved  
when  
the meter reads traffic off a live interface. I have checked my code, as  
well  
as the pcap\_misc.rb and pcaplet.rb files within the Ruby PCAP module and  
I am  
not sure where these calls are being made. I was wondering if anyone  
familiar  
with the Ruby PCAP module could inform me where the call to Range.each  
is being  
made as  
I am now in the process of trying to improve my meter’s performance.  
Thank you  
for your time.

cheers,

Damir

---

<div class="post-metadata">

**Author:** ![Damir\_Azhar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e5b9ba/32.png) [@Damir\_Azhar](https://www.ruby-forum.com/u/Damir_Azhar)\
**Post date:** [May 25, 2006, 7:17am UTC](https://www.ruby-forum.com/t/no-subject/95231/2 "2006-05-25T07:17:33Z")

</div>

Hi,

I have been using the Ruby PCAP module to implement a simple network  
traffic  
flow meter based on the RTFM architecture. When I run my meter with the  
Ruby  
profiler option, I have discovered that the biggest single chunk of  
processing  
time goes to calls to the “each” function of the Range class, with calls  
to  
this method accounting for up to 23% of total processing time when the  
meter  
reads traffic data off trace files. This figure is approximately halved  
when  
the meter reads traffic off a live interface. I have checked my code, as  
well  
as the pcap\_misc.rb and pcaplet.rb files within the Ruby PCAP module and  
I am  
not sure where these calls are being made. I was wondering if anyone  
familiar  
with the Ruby PCAP module could inform me where the call to Range.each  
is being  
made as I am now in the process of trying to improve my meter’s  
performance.  
Thank you for your time.

cheers,

Damir

---

<div class="post-metadata">

**Author:** ![Damir\_Azhar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e5b9ba/32.png) [@Damir\_Azhar](https://www.ruby-forum.com/u/Damir_Azhar)\
**Post date:** [May 25, 2006, 9:43am UTC](https://www.ruby-forum.com/t/no-subject/95231/3 "2006-05-25T09:43:44Z")

</div>

Just speculation: it’d guess that the `each` method of `Capture`  
gets called once for every packet. That would explain why it’s called  
so often. When you load a capture from a file, it may get called once  
while loading each packet and once when you loop through them, which  
would explain the halfing during live captures.

Provide the relevant bits of code and traces and we might be able to  
make further guesses…  
-tim
