Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: new DLL compile code inside script languages

by Jorge_de_Burgos (Beadle)
on Jul 05, 2009 at 15:40 UTC ( #777350=note: print w/replies, xml ) Need Help??


in reply to new DLL compile code inside script languages

This would be a minimum inline-C procedure in Perl. Very fast. Very short!
#!/usr/bin/perl use Inline C; print suma(100_000_000); __END__ __C__ double suma(double n) { double i, sum = 0; for (i=1; i<=n; i++) { sum += i; } return sum; }

Replies are listed 'Best First'.
Re^2: new DLL compile code inside script languages
by roboticus (Chancellor) on Jul 05, 2009 at 17:39 UTC
      Listen roboticus, we are comparing brute-force approaches here...
        Jorge de Burgos:

        True ... but I was just trying to illustrate that it's often the case that looking for a better algorithm is more productive than optimizing the current code.

        ...roboticus

        But that's not a very good thing to compare. What does it tell you? That C is faster than Perl for a very specific case of tight loops and integer arithmetic that is rendered totally moot by the existence of a trivial O(1) algorithm.

        What it doesn't tell you is whether Perl, Inline::C, PDL, or this VB-inspired DLL is a good choice for any real-world problem. It does not implement an interesting algorithm, so you can't compare which provides the most readable implementation; and it does not benchmark an interesting calculation, so you can't really compare performance either.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (6)
As of 2023-01-27 23:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?