Attempting to place the C code as a string directly into the benchmarking script, a new error was produced.
Error. You have specified 'C' as an Inline programming language.
I currently only know about the following languages:
If you have installed a support module for this language, try deleting
+ the config-xxx-xxx-xxx-5.020003 file from the following Inline DIREC
+TORY, and run again:
(And if that works, please file a bug report.)
at ./calcit.pl line 14.
BEGIN failed--compilation aborted at ./calcit.pl line 14.
So it may be that there needs to be some further modules installed for Strawberry Perl to use Inline.pm with C.
Replacing END with DATA unfortunately still produces the original Error. I tried to open Inline::DATA as a file handle, but I couldn't quite apply IO calls to pseudo Handles. Also tried various permutations of the examples on C-PAN and in the Cookbook. See below for Code which produced new error. Also note Inline::Files did not install when I ran the cpan install Inline cmd
use File::Spec::Functions qw/catfile/;
use lib catfile('C:', 'Users', 'home', 'Perl5', 'lib', 'perl5' ) ;
use Time::HiRes qw(gettimeofday tv_interval);
use Inline C => '<<END_C';
double my_abs(double num)
return (num > 0)? num : -num;
double real_pi = 3.14159265358979;
double my_pi = 0;
double step_sign = 1;
unsigned long long i = 1;
while(my_abs(real_pi - my_pi) > 0.00000001)
my_pi += 4.0/i * step_sign;
step_sign *= -1;
i += 2;
my $start_time_c = [ gettimeofday ];
my $c_calc = calc_pi(); #c_calc::calc_pi();
my $end_time_c = [ gettimeofday ];
my $elapsed_c = tv_interval($start_time_c,$end_time_c);
my $start_time_perl = [ gettimeofday ];
my $perl_calc = 3.14159 ** 2.71828; #perl_calc::calc_pi();
my $end_time_perl = [ gettimeofday ];
my $elapsed_perl = tv_interval $start_time_perl,$end_time_perl);
my $differences = abs($elapsed_perl - $elapsed_c);
#if(ok($c_calc == $perl_calc, "Pi number calc"))
if($c_calc != $perl_calc)
print "C computation time = $elapsed_c\n";
print "Perl computation time = $elapsed_perl\n";
print "Differences = $differences\n";
Frustratingly, when no use of the DATA symbol occurs there are still attempts to read the unopened handle. Hope this helps progress the issue. DC.