Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: calling perl from C [performance optimization]

by ikegami (Patriarch)
on Dec 15, 2005 at 07:39 UTC ( [id://516882]=note: print w/replies, xml ) Need Help??


in reply to calling perl from C [performance optimization]

1) Why don't you embed the Perl "interpreter" in the C application? See perlembed

2) Alternatively, it would surely be faster to launch a single Perl process and send the 40000 requests to it (via a pipe or whatever), rather than launching 40000 Perl processes (which requires compiling the script and the modules it uses every time).

3) Yet another possibility is to have the C program output a Perl program. This is particulary useful when each call to Perl is independant of the others. For example, the Perl script might look like:

use Guts; guts(value_calulated_by_C_1); guts(value_calulated_by_C_2); ... guts(value_calulated_by_C_40000);

After running this one Perl script, the C program could process the output if need be.

Replies are listed 'Best First'.
Re^2: calling perl from C [performance optimization]
by ikegami (Patriarch) on Dec 15, 2005 at 16:01 UTC
    Elaboration on #3, by request:

    If your script normally looks like

    $value = ...from @ARGV from C program... guts($value);

    then I'm simply suggesting the C program could create a .pl that calls guts multiple times with the appropriate values hardcoded.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2024-04-25 12:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found