Dear Monks:

I am a bioinformatics programmer and I am currently running a very large calculation looking for subgraph isomorphisms. I have optimized it to the best of my abilities (I'm limited to the scale of my rewriting since the underlying objects/modules are used in much of my other code)

Below is a subroutine that currently consumes 74% of the time in my multiday calculation, even when using a cluster with torque. I have tried various different things, but I cannot beat what I have and any improvement would save me considerable time.

sub equate2 { my ($self, $other, $mapping) = @_; foreach my $row_index (0..$#$mapping) { return 0 if (grep { $$self{Matrix}[$row_index][$_] != $$other{Matr +ix}[$$mapping[$row_index]][$$mapping[$_]]); } (0..$#$mapping)); } return 1; }

I can provide more information if necessary, but in short this subroutine finds if elements of two matrices, i and j determined by a vector: $mapping.

Any advice and any tips for improving performance would be greatly appreciated. I have tried switching out the grep and foreach with for statements to no avail.

Thanks to all the monks for the help you have given in the past.


In reply to Optimization Help by jmmitc06

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.