TheFifthDeuce has asked for the wisdom of the Perl Monks concerning the following question:

I know, I know...comparing apples and oranges here. Just thought I would share an interesting stat though, as it does pertain to a question that I posted in here about a problem I had with RAM being devoured in a Perl script I wrote.

I wrote 2 similar progs...one in Perl, the other in C++. They both factor numbers. Using 100 million, Perl found all factors in 2 minutes and 28 seconds. C++ did the same in 18 seconds. I am bringing this up because I had a big problem involving using an array with a huge amount of elements, and I couldn't figure out what was eating RAM. I had been jumping back and forth between C++ and Perl lately, and since I never had this problem with C++ arrays, I totally overlooked it in Perl!lol

Although my benchmark test of 'speed' doesn't necessarily have to corrolate with RAM, it's just the whole principle of realizing your limitations on what you are working with. And actually, 'limitations' is not the correct term here, as after posting my problem the other day, many of you showed me another way of fixing my problem easily using the substr function...TIM TOWTDI to the rescue!lol

Anyways, thanks to all for the advice. The prog I was working on in which I initially posted about is a pretty cool encryption system written fully in Perl. Well it is now complete and up and running online. I also made a standalone of it for download. Check it out here if ya want:

http://www.trixmaster.com/designs/encrypter.pl

Thanks again,
David

edited: Sat Aug 3 21:50:38 2002 by jeffa - fixed borked link

Replies are listed 'Best First'.
Re: Benchmark C++ vs Perl
by dws (Chancellor) on Aug 03, 2002 at 03:59 UTC
    Another benchmark to consider is how long it took to get it running. For problems that you only need to solve once, running in two and a half minutes vs. 18 seconds still wins if you finish the former script a half day ahead of the second one.

    I wrote 2 similar progs...one in Perl, the other in C++.

    How long did it take you to each one working?

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: Benchmark C++ vs Perl
by DamnDirtyApe (Curate) on Aug 02, 2002 at 23:01 UTC

    Of course, when you absolutely, positively need the speed, you can use Inline::C or Inline::CPP to write C/C++ within your Perl code.


    _______________
    DamnDirtyApe
    Those who know that they are profound strive for clarity. Those who
    would like to seem profound to the crowd strive for obscurity.
                --Friedrich Nietzsche
Re: Benchmark C++ vs Perl
by crenz (Priest) on Aug 02, 2002 at 23:37 UTC

    Both languages have their limitations. I remember reading one Benchmark years ago, where they implemented a text-file processing problem in different languages. The ranking was as follows:

    1. C
    2. Perl
    3. C++
    4. Java

    Now, if I could just remember the reference...

    Of course, comparing languages can be rather arbitrary. You have to make sure your implementations are really equivalent (for example, a C++ array is not equivalent to a Perl array).

Re: Benchmark C++ vs Perl
by Anonymous Monk on Aug 03, 2002 at 02:28 UTC
    It sounds like you have a bad factoring algorithm. Re (tilly) 1: Factoring Decimal Digits shows a much better one.

    As for your "pretty cool encryption system", why should I trust an unverified encryption system written by a novice programmer? (Before you get offended by that characterization, learn how to write a link that will work in a browser other than IE.)

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