Subject:
Re: C++ vs. Python vs. Perl vs. PHP performance benchmark
From:
Isaac Gouy
Date:
22.6.2012 г. 21:30 ч.
To:
Ivan Zahariev

Hi Ivan



> I don't care what Python, Java, PHP or any of the other languages are doing while I want
> them to do a task with "loops, dynamic arrays with numbers, basic math operations". The 
> idea is to compare exactly this overhead and efficiency.

Readers of your blog post don't know, that you don't care what the programs are doing :-)

Readers of the blog post don't know, whether the overhead might be something *accidental* that you've created because of the way you've chosen to run the programs ;-)


> I've already commented #3 -- you are right, but I don't have the time to 
> update this, and frankly since Java and Python/PHP/Perl are different 
> kind of languages, I think that we may leave that as-is. Write a comment 
> about this at the blog, and I'll reply the same, so that we have a 
> public log of this.

You told me that - "This is a fair competition with fair rules -- every language uses the very same algorithm."

If you want to show optimised programs for Python/PHP/Perl but not for C++/Java, then please just say so at the top of your blog post ;-)


> Regarding #5 -- I don't really understand what you mean here. I test the 
> default languages setup. I have no idea what the size of a 
> Python/Perl/PHP/Java list is. And I won't tweak any of the 
> implementations by optimizing them for the current task/algorithm. This 
> is a general test, not a try to complete a task in the fastest possible 
> way for each programming language.

 
1) You've told me that you aren't a Java programmer -- well, I wouldn't call myself a Java programmer, but I have been paid to write Java programs, so I know something about how Java programs are expected to work. I know that the expectation is that programs which allocate a lot of memory are not expected to be run with default heap sizes --

       "Large server applications often experience two problems with these defaults. 
        One is slow startup, because the initial heap is small and must be resized over
        many major collections. A more pressing problem is that the default maximum 
        heap size is unreasonably small for most server applications. The rules of 
        thumb for server applications are:

                Unless you have problems with pauses, try granting as much memory as 
                possible to the virtual machine. The default size (64MB) is often too small."


2) The "Java (non-std lib)" program IS tweaked for the current task/algorithm -- so please don't show it!

(IntList is hard-coded to use int primitives, and the default capacity is 100x larger than ArrayList, and the operations are not range-checked, and there's no way to remove items, and...) 


3) When you say "this is a general test", that makes me think that you don't know that "the default" Java heap size will change depending on how much memory is installed on the computer. 

Run your Java program unchanged on a computer with 64GB memory and the heap size "defaults" will be:
       -Xms1G -Xmx1GB
:and *by accident* your Java program could be X times faster!

There's no such thing as "a general test".


4) You had the curiosity to see if you "could greatly speed up the execution of any Python code without any modifications", so please have the curiosity to see if you can greatly speed up the execution of the Java program you wrote, "without any modifications" --  simply by doing what is expected and setting the initial heap size.

If you really don't want to show how slow and how fast your Java program can be, then please just say so at the top of your blog post. Readers of your blog post deserve to know.


best wishes, Isaac