Just another idea based on tuning your current algorithm which is quite clever! (Well after being understood - you know my opinion about clear naming ;-)

After analyzing the numbers you provided, I suppose that intersections of different ranges are comparatively rare and if they appear they stretch over long distances.

So it doesn't really make sense to go into the count loop for each individual point, just go on counting the "1" till you reach the next "boundary" and add them collectively to your counter instead incrementing them one by one with++.

The boundaries are nothing else as the sorted list of range starts-1 and stops. In your example for ID "b"

ID start stop ... b 10 15 b 12 15

this means [9,11,15].

and results in the following flow

0-9 => ignore 10-11 => count 1 x "1" => add 1 to range [10-15] 12-15 => count 4 x "1" => add 4 to range [10-15] and [12-15] 16- => ignore

As you see, you can also stop counting between ranges and even try to jump forward in the file with seek.

HTH! =)

Update: Approximation

3e6 Intervals/50 IDs *2 Borders = 120000 Borders

6e9 Points / ID

=> in average 6e9/12e4=50000 points between two adjacent borders, where you can avoid the whole count loop.

This should lead to a considerable boost!

Cheers Rolf

( addicted to the Perl Programming Language)


In reply to Re: Counter - number of tags per interval by LanX
in thread Counter - number of tags per interval by baxy77bax

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.