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.