Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Perl 5, Python, Rakudo, C/C++, Java, Lua?

by Tux (Canon)
on Mar 14, 2015 at 10:08 UTC ( [id://1120037]=note: print w/replies, xml ) Need Help??


in reply to Perl 5, Python, Rakudo, C/C++, Java, Lua?

Inline::Perl5 now supports passing IO (including deep and dark IO from within XS), so this code works:

use v6; use Slang::Tuxic; use Inline::Perl5; my $p5 = Inline::Perl5.new; $p5.use ("Text::CSV_XS"); my @rows; my $csv = $p5.invoke ("Text::CSV_XS", "new") or die "Cannot use CSV: ", $p5.invoke ("Text::CSV_XS", "error_diag +"); $csv.binary (1); $csv.auto_diag (1); my $fh = open "/tmp/hello.csv", :r, chomp => False; my Int $sum = 0; while (my $r = $csv.getline ($fh)) { $sum += +$r; } $sum.say;

To give an example of performance (seconds needed to parse 10000 lines of 5 fields each). Note that Text::CSV::Easy_* only accepts valid CSV and has no options.


Perl 5

Text::CSV::Easy_XS0.019
Text::CSV::Easy_PP0.017
Text::CSV_XS with bind_columns0.033
Text::CSV_XS0.038
Text::CSV_PP0.517
Pegex::CSV1.350

Perl 6

State machine (no options yet)7.027
Inline::Perl5 + Text::CSV_XS13.082
Inline::Perl5 + Text::CSV_XS + getline (IO)13.142
Inline::Perl5 + Text::CSV_PP13.623
Grammar-based (no options yet)13.210
Regex based (no options)39.996
Regex based, all options provided36.075

When I started in october 2014, the Regex based solution took 260 seconds, so improvement in the language itself is made on a daily basis!


Enjoy, Have FUN! H.Merijn

Replies are listed 'Best First'.
Re^2: Perl 5, Python, Rakudo, C/C++, Java, Lua?
by Jenda (Abbot) on Mar 27, 2015 at 20:25 UTC

    Thanks for the benchmarks! Come back when, or I should rather say, if you succeed to make something that's not several hundred times slower than something that actually works. I doubt you ever will.

    Ada attracted much attention from the programming community as a whole during its early days. Its backers and others predicted that it might become a dominant language for general purpose programming and not just defense-related work. Ichbiah publicly stated that within ten years, only two programming languages would remain, Ada and Lisp. Early Ada compilers struggled to implement the large, complex language, and both compile-time and run-time performance tended to be slow and tools primitive. Compiler vendors expended most of their efforts in passing the massive, language-conformance-testing, government-required "ACVC" validation suite that was required in another novel feature of the Ada language effort.

    You are building another Ada, this time without the backing of DoD and, more importantly, with no chance of a Perl6 mandate.

    Jenda
    Enoch was right!
    Enjoy the last years of Rome.

    A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (6)
As of 2024-04-24 12:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found