Hacker News new | ask | show | jobs
by eggsnbacon1 2224 days ago
My Java timing is very close to Rust. I have a feeling PyPy is eliminating the string conversion as dead code. When I alter my Java toy code to not prevent elimination of the toString() call it runs close to speed of PyPy.
2 comments

> I have a feeling PyPy is eliminating the string conversion as dead code.

If I'm not mistaken, the specific variation of the benchmark shown upthread could not be eliminating the string conversion, as it's adding the length of the resulting string to a variable which is later printed.

> len(str(i))

I found Java's to be quicker than Rust:

Java:

    time java Test
    117777800
            0.60 real         0.52 user         0.12 sys
Rust:

    time ./test
    117777800
            1.94 real         1.89 user         0.00 sys
What flags did you use with Rust?
Both `-O` and `-C opt-level=3`. I'm guessing this is one of those high throughput scenarios where having a GC is quicker because it's able to defer deallocation until the end of the program.
-O is opt level 2, incidentally.

Yeah, I think you’re right. Very interesting!