🐌 Processing FFI on each request is slow, but preloading is fast! 🚀


preload.inc:


<?php
FFI
::load(__DIR__ '/astro-preload.h');
astro-preload.h:


#define FFI_SCOPE "ASTRO"

void sunpos(double d, double *L, double *M, double *ra, double *decl, double *rad);
Run:


<?php
$ffi 
FFI::scope('ASTRO');

$ffi
->sunpos(
    
$dayNr,
    
FFI::addr($L), FFI::addr($M), FFI::addr($ra), FFI::addr($decl), FFI::addr($rad)
);