Is there any language that native-compiles faster than D?

James Lu jamtlu at gmail.com
Wed Aug 26 16:00:26 UTC 2020


On Wednesday, 26 August 2020 at 14:45:48 UTC, Steven 
Schveighoffer wrote:
> On 8/25/20 9:13 PM, James Lu wrote:
>> V8 JavaScript compiles faster:
>> 
>> $ d8 --always-opt --trace-opt --single-threaded
>
> I just want to point out that ts is not an accurate 
> timestamping system. The shell is starting ts and d8 
> simultaneously, and it's very possible that d8 has done a lot 
> of stuff by the time ts gets around to deciding what timestamp 
> 0 is. In fact, d8 could be completely finished, and all its 
> output buffered in the pipe, before ts does anything. 
> Especially when these times are so short.
>
> Not saying the data is wrong, but I am not certain this is 
> proof.
>
> Use shell time builtin.
>
> -Steve

$ time d8 --always-opt --trace-opt --single-threaded 
--no-compilation-cache mandelbrot.js
[compiling method 0x182b08210471 <JSFunction (sfi = 
0x182b08210129)> using TurboFan]
[optimizing 0x182b08210471 <JSFunction (sfi = 0x182b08210129)> - 
took 0.888, 1.326, 0.026 ms]
[optimizing 0x182b0821073d <JSFunction main (sfi = 
0x182b082101e5)> because --always-opt]
[compiling method 0x182b0821073d <JSFunction main (sfi = 
0x182b082101e5)> using TurboFan]
[optimizing 0x182b0821073d <JSFunction main (sfi = 
0x182b082101e5)> - took 0.401, 3.229, 0.044 ms]
[optimizing 0x182b08085bdd <JSFunction Complex (sfi = 
0x182b0821021d)> because --always-opt]
[compiling method 0x182b08085bdd <JSFunction Complex (sfi = 
0x182b0821021d)> using TurboFan]
[optimizing 0x182b08085bdd <JSFunction Complex (sfi = 
0x182b0821021d)> - took 0.138, 0.296, 0.028 ms]
[optimizing 0x182b08210709 <JSFunction iterate_mandelbrot (sfi = 
0x182b082101ad)> because --always-opt]
[compiling method 0x182b08210709 <JSFunction iterate_mandelbrot 
(sfi = 0x182b082101ad)> using TurboFan]
[optimizing 0x182b08210709 <JSFunction iterate_mandelbrot (sfi = 
0x182b082101ad)> - took 0.228, 1.619, 0.035 ms]
[optimizing 0x182b08085bfd <JSFunction abs (sfi = 
0x182b08210255)> because --always-opt]
[compiling method 0x182b08085bfd <JSFunction abs (sfi = 
0x182b08210255)> using TurboFan]
[optimizing 0x182b08085bfd <JSFunction abs (sfi = 
0x182b08210255)> - took 0.213, 0.502, 0.033 ms]
[optimizing 0x182b08085c35 <JSFunction mul (sfi = 
0x182b082102c5)> because --always-opt]
[compiling method 0x182b08085c35 <JSFunction mul (sfi = 
0x182b082102c5)> using TurboFan]
[optimizing 0x182b08085c35 <JSFunction mul (sfi = 
0x182b082102c5)> - took 0.183, 0.643, 0.030 ms]
[optimizing 0x182b08085c19 <JSFunction add (sfi = 
0x182b0821028d)> because --always-opt]
[compiling method 0x182b08085c19 <JSFunction add (sfi = 
0x182b0821028d)> using TurboFan]
[optimizing 0x182b08085c19 <JSFunction add (sfi = 
0x182b0821028d)> - took 0.150, 0.449, 0.041 ms]

real	0m0.052s
user	0m0.022s
sys	0m0.021s

--always-opt makes V8 compile the function the first time it is 
called, so we can ignore interpreter overhead. I changed the code 
to quit after one function call, so we would measure how long it 
takes to compile and run the compilation.

For the sake of transparency, I modified some of the code to move 
it into a main function to ensure it would compile the code. 
Surprisingly, doing this reduced compilation time.

Here is the exact code I used: 
https://gist.github.com/CrazyPython/3552e1405dbb4b640810f6443cd0a015


More information about the Digitalmars-d mailing list