Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^3: Inline::C on Windows: how to improve performance of compiled code?

by syphilis (Archbishop)
on Jun 15, 2018 at 09:02 UTC ( #1216702=note: print w/replies, xml ) Need Help??


in reply to Re^2: Inline::C on Windows: how to improve performance of compiled code?
in thread Inline::C on Windows: how to improve performance of compiled code?

Looks to me, "C from C" on Windows got optimized away

I don't think so. (Could be wrong but.)
A clearer ilustration is (hopefully) this script:
use Time::HiRes qw(time); use Inline C => Config => #OPTIMIZE => '-O0', FORCE_BUILD => 1; use Inline C => <<'EOC'; void foo() {} void foo_bar(int x) { int i; for(i = 0; i < x; i++){ foo(); } } EOC $iterations = 10000000; $t = time; foo() for 1 .. $iterations; print "# ", time - $t, "\n"; $t = time; foo_bar($iterations); print "# ", time - $t, "\n";
As it stands, with optimization enabled, it outputs (on Windows):
# 1.02960205078125 # 1.00135803222656e-005
Now that second value does look like something was optimized away. I'm thinking the loop is simply doing nothing at each iteration.
When we switch optimization off by including the "OPTIMIZE => '-O0'" line, the output changes to (on Windows):
# 1.10760188102722 # 0.0196361541748047
The "C from C" code now takes 500 times longer to execute - because, I think, this time foo() is actually being called at each iteration. But it's still 50 times quicker than calling "C from Perl".

I've no useful ideas regarding things that can be done to enable Windows to access C subs as quickly as it can access Perl subs - and that's the main reason that I'm avoiding that aspect.

Cheers,
Rob

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1216702]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2022-08-10 11:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?