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

ikegami: I can't compile your C code with my perl code :(

Replies are listed 'Best First'.
Re^3: Inline C + IO::Handle
by ikegami (Patriarch) on Apr 17, 2009 at 00:28 UTC
    I fixed the compilation errors. But like I said, it would make more sense to actually call print:
    package MyModule; use Inline Config => ( DIRECTORY => './Inline', ); use Inline 'C'; sub _fprint { print { shift } @_ } # ... 1; __END__ __C__ int my_print(SV* fh, SV* sv) { int result; dSP; ENTER; SAVETMPS; PUSHMARK(SP); XPUSHs(fh); XPUSHs(sv); PUTBACK; call_pv("MyModule::_fprint", G_SCALAR); SPAGAIN; result = POPi; PUTBACK; FREETMPS; LEAVE; return result; }
      > 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 :)
        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.