Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • Note that I upped the number of iterations to 1,000,000. Does Rakudo have inline C capability? For something that is numeric intensive, you might want a sharper tool.

    #include <stdio.h>
    main() {
        int i=0;
        int limit=1000000;
        int array[limit];

        while (i<limit-1) {
        //printf("I is %d", i);
            array[i]=i;
            i++;
        }
    }
    phred@harpua ~ $ time ./a.out

    real    0m0.015s
    user    0m0.006s
    sys     0m0.005s

    #!/usr/bin/perl -w

    my $i = 0;
    my @numbers;
    until ( $i == 1000000 ) {

        $numbers[$i] = $i;
        $i++;
    }

    phred@harpua ~ $ time perl p5.pl

    real    0m0.384s
    user    0m0.220s
    sys     0m0.022s

    • I think if you'll reread the article, you'll find that he's a Perl fan, and wants to use Perl 6, but is concerned about what is an obvious performance problem in this part of the code at this time.

      The original poster is not asking for the best way to solve the problem of counting up to 100,000.

      --

      --
      xoa