The code was somewhat faked up because I didn't have access to the details and they don't actually matter much anyway. The code is actually in a multiple channel sampling system used for biological signals. It does sample 24 bits (at around 40 kHz), but most of the signal processing is 32 bits and the final output is 16 bits (at around 120 kHz)! But to satisfy curiosity somewhat the code is currently:

out = new RingBufferEnum(in.get(), 2 * PI * (9*5));

The 9 is a decimation ratio. I can't remember what the 5 is (maybe an interpolation ratio?), and the 2 * PI is a fudge factor we determined by in essence profiling the code (with a logic analyser actually).

There was extensive discussion around the buffer sizes, but at a higher "philosophical" level that didn't really touch on the magic numbers. Oh and look, here's the original code:

//This somewhat empirical value of 4, in combination with a kMinSample +sToProcess //= 16, gives the best performance in the sense of minimizing the like +lihood of //DAC buffer underflow and ADC buffer overflow during the period just +after //sampling starting when the filters are initialising. const int kMultirateInitNumInnerSamples = 2; ... out = new RingBufferEnum::Enum( in.get(), (9*5) + 5, 9 * 5 * kMultirat +eInitNumInnerSamples);

Note the rather worrying disconnect between 4 in the comment and the actual constant value of 2!

The whole exercise was not a shining example of a team pulling together, but the situation was complicated by factors beyond our control.

Premature optimization is the root of all job security

In reply to Re^5: Perl vs Python revisited by GrandFather
in thread Perl vs Python revisited by QuillMeantTen

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.