title: Simultaneous calls from CDR
body: <p>I need to come up with an analysis of simultaneus events, when having only starttime and duration of each event.</p>
  
  <p><strong>Details</strong></p>
  
  <p>I've a standard CDR call detail record, that contains among others:</p>
  
  <ul>
  <li>calldate (timedate of each call start</li>
  <li>duration (int, seconds of call duration)</li>
  <li>channel (a string)</li>
  </ul>
  
  <p>What I need to come up with is some sort of analysys of simultaneus calls on each second, for a given timedate period. For example, a graph of simultaneous calls we had yesterday.</p>
  
  <p>(The problem is the same if we have visitors logs with duration on a website and wish to obtain simultaneous clients for a group of web-pages)</p>
  
  <p>What would your algoritm be?</p>
  
  <p>I can iterate over records in the given period, and fill an array, where each bucket of the array corresponds to 1 second in the overall period. This works and seems to be fast, but if the timeperiod is big (say..1 year), I would need lots of memory (3600x24x365x4 bytes ~ 120MB aprox).</p>
  
  <p>This is for a web-based, interactive app, so my memory footprint should be small enough. </p>
  
  <p><strong>Edit</strong></p>
  
  <p>By simultaneous, I mean all calls on a given second. Second would be my minimum unit. I cannot use something bigger (hour for example) becuse all calls during an hour do not need to be held at the same time.</p>