Hacker News new | ask | show | jobs
by igouy 2417 days ago
> will show whether it uses MJIT correctly

    …
    JIT success (511.7ms): initialize@nbody.rb:14 -> /tmp/_ruby_mjit_p5804u105.c
    JIT success (397.5ms): block in offset_momentum@nbody.rb:68 -> /tmp/_ruby_mjit_p5804u106.c
    JIT success (607.0ms): block in energy@nbody.rb:50 -> /tmp/_ruby_mjit_p5804u108.c
    JIT compaction (53.6ms): Compacted 111 methods -> /tmp/_ruby_mjit_p5804u111.so
    Successful MJIT finish

    real 6m4.201s
    user 6m42.813s
    sys 0m4.041s



    $ time /opt/src/php-7.3.11/bin/php -n  nbody.php 50000000
    -0.169075164
    -0.169059907

    real 5m24.915s
    user 5m24.808s
    sys 0m0.020
1 comments

As for mine, Ruby slightly faster 4:05s - 4:09s which is close to PHP in timing.

ruby 2.7.0dev (2019-11-23T07:06:30Z master b563439274) [x86_64-darwin18]

gtime -v /usr/local/bin/ruby --jit -W0 nbody.rb 50000000 -0.169075164 -0.169059907

Command being timed: "/usr/local/bin/ruby --jit -W0 nbody.rb 50000000"

User time (seconds): 249.30 System time (seconds): 0.58 Percent of CPU this job got: 100% Elapsed (wall clock) time (h:mm:ss or m:ss): 4:08.97

---

PHP 7.3.11 (cli) (built: Oct 24 2019 11:29:52) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.3.11, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.3.11, Copyright (c) 1999-2018, by Zend Technologies

gtime -v php -n nbody.php 50000000

-0.169075164 -0.169059907

Command being timed: "php -n nbody.php 50000000" User time (seconds): 248.02 System time (seconds): 0.49 Percent of CPU this job got: 99% Elapsed (wall clock) time (h:mm:ss or m:ss): 4:09.82