Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Re: Profiling forking code?

by Jeppe (Monk)
on Jan 13, 2003 at 22:00 UTC ( #226619=note: print w/replies, xml ) Need Help??


in reply to Re: Profiling forking code?
in thread Profiling forking code?

Hmm. It's never that easy.

As it turns out, DProf segfaults while Devel::Profiler screws up the file when confronted with my scary class definition logic. What I'm doing is VERY insecure, so only do this if you TRUST your users.

I've designed it so that one general class is a shell around the class I load. I've done this for several reasons

  1. If there is a syntax error in one of the classes, I don't want bring down the entire process.
  2. I want to give my customers the chance to create their own code that ties in, without altering the core code
  3. I got a performance improvement when using this method over regular inheritance
Anyhow, I have a class. The objects have an associated file, and that file contains part of the code - using a standard API. So, I create a header and a footer, and insert the code from the file inbetween. Then, I run a string eval around that, and then I have a new child class. I create an object of the child class, and keep it as a variable in the parent class. Inside the parent class, I call that object where appropriate.

As it turns out, the profilers do not approve of this.

Any brilliant ideas, fellow monks? Need I rewrite, or do you see a way for me to work around my problem?

Replies are listed 'Best First'.
Re^3: Profiling forking code?
by tall_man (Parson) on Jan 13, 2003 at 22:44 UTC
    According to perldebguts:
    A hash %DB::sub is maintained, whose keys are subrou­tine names and whose values have the form "file­name:startline-endline". "filename" has the form "(eval 34)" for subroutines defined inside "eval"s, or "(re_eval 19)" for those within regex code assertions.

    It seems to me your profiler would be happier (and you would find the output more usable) if you pre-created the object packages and used them from files instead of creating them inside eval.

      If I did that, I would remove quite a few reasons why I use perl rather than java. Hmm. I wonder if I can make a script that creates those classes for me, rather than loading those classes in the current way. Just for testing.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://226619]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2022-01-16 11:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (49 votes). Check out past polls.

    Notices?