开发者

What is the CORE:match (opcode) subroutine in Perl profiling?

I previously wrote some utilities in Perl, and I am now rewriting them in order to give s开发者_运维技巧ome new/better features. However, things seem to be going much more slowly than in the original utilities, so I decided to run one with the NYTProf profiler. Great profiler btw, still trying to figure out all its useful features.

So anyway, it turns out that 93% of my program's time is being spent on calls to the GeneModel::CORE:match (opcode) subroutine, and I have no idea what this is. Most Google hits point to NYTProf profiles others have posted. I indeed wrote the GeneModel class/package, but I don't know what this subroutine is, why it was called so many times, or why it's taking so long. Any ideas?


CORE:match is a call to a regular expression -- in this case, within your GeneModel package.

For example, if we profile this script, Devel::NYTProf reports 1000 calls to Foo::CORE:match.

use strict;
use warnings;

package Foo;
my $s = 'foo foo';
$s =~ /foo/ for 1 .. 1000;


Perl is compiled to opcodes. The match operator results in a match opcode.

> perl -MO=Terse -e'm//'
LISTOP (0x8c4b40) leave [1]
    OP (0x8c4070) enter
    COP (0x8c4780) nextstate
    PMOP (0x8c4260) match

This is not a subroutine, but merely represented that way as opcode profiling is a recent addition and the UI hasn't been overhauled yet to take that into account. In simple words, the profiler is telling you that most time is spent in the regex engine.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜