Brethren,

I have recently begun the journey to CS enlightenment, with all its algorithm efficiency, holy "O" notation, and other joyous wonders1. I have encountered a wall of thorns along this path.

At the moment I'm working with sort functions that need to read data from the disk, sort, then store back to the disk. Various constraints and data sets are provided, sometimes you have to have fit a sort into $i Mb or have it run under $j seconds2. Prior to this I was happily using Benchmark, however the new memory considerations preclude its use as the sole tool. Checking CPAN's Devel and other packages turned up nothing that dealt with memory profiling. After reading a bit more into Perl’s memory management, reference counting, garbage collection, and general recycling... it became apparent how naïve I was in this respect. A straight comparison inside the same runtime interpreter would have produced incredibly skewed results anyways.

This leaves me where I am now, concerned with relative performance in memory, speed, and scratch space between scripts yet with no overall way to compare. I'd guess some type of fork() call w/ IPC or an external framework are needed but I'm only beginning programming so these are, for the moment, well beyond my ability to write.

I ask unto ye, are there readily available tools for doing these comparisons?

-- Brother Arguile


1 I realise Perl is not considered by some to be the ideal language to learn this in, but I have to balance my immediate professional needs with the time consuming theoretical material. It simply doesn't make sense to jump into Scheme or C/C++ full force at this time.

2 At this point I'm not so concerned with absolute limits as relative performance.


In reply to Benchmarking with Memory Profiling by Arguile

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.