in reply to Re^3: Inline C + IO::Handle
in thread FCGI + Inline::C fast stream out!

> But like I said, it would make more sense to actually call print:

I understand your idea, but i have to benchmark FastCGI perl output and C output. If i call perl "print" my idea is not working. I already benchmarked output large string to /dev/null and C code is more faster than perl. My idea compare FastCGI output, but i cant understand how to do it :)

Replies are listed 'Best First'.
Re^5: Inline C + IO::Handle
by ikegami (Patriarch) on Apr 17, 2009 at 13:41 UTC
    If you're interested in optimising and don't need a generic solution, then Re^2: Inline C + IO::Handle is going to be fastest. Replace MyFH with whichever namespace the FCGI handle is tied to. Magic is (relatively) slow, and this will avoid it completely.
      I try to do this, but C function dont print to stream :( Maybe i have mistake in code?
      sub main { my $proc_manager = new FCGI::ProcManager({ n_processes => $PRO +CESSES}); my $socket = FCGI::OpenSocket($SOCKET, 100); my $request = FCGI::Request(\*STDIN, \*STDOUT, \*STDERR, \%ENV +, $socket); my (undef, $out, undef) = $request->GetHandles(); $proc_manager->pm_manage(); while($request->Accept() >= 0){ $proc_manager->pm_pre_dispatch(); my $cgi = CGI::Fast->new(); print "Content-type: text/html\r\n\r\n"; my_print_c($out); $proc_manager->pm_post_dispatch(); } FCGI::CloseSocket($socket); } __END__ __C__ void my_print_c(SV * fh) { dSP; ENTER; SAVETMPS; PUSHMARK(SP); XPUSHs(sv_2mortal(fh)); XPUSHs(sv_2mortal(newSVpv("TEXT", 0))); PUTBACK; call_pv("PRINT", G_DISCARD); FREETMPS; LEAVE; }

        You're doing

        PRINT($out, "TEXT");

        when you want to do

        tied(*$out)->PRINT("TEXT");