1 year ago
#368341
Waleed
Dart vs PHP, PHP way faster compared to Dart (aot)
I started recently learning Dart for server side as I like its syntax and aot concept. I wrote a simple script in both language and seems PHP way faster than Dart generated AOT executable.
Dart Code
import "dart:io";
main() {
var i = 0;
while (true) {
stdout.write("i = $i\n");
if (i == 1000000) {
break
}
i++;
}
}
Compiled with:
dart compile exe file-name.dart
PHP
<?php
$i = 0;
while (true) {
print("i = $i\n");
if ($i === 1000000) {
break;
}
$i++;
php file-name.php
Performance
My question is why PHP is faster by ~50% than Dart?
Even I tried to run the dart first without measure-command
until I see dart app prints to the screen, then I run php, php still go way faster until it pass the dart printed i
value
I am not sure if I did something wrong, as I know that AOT compiles to native code and I know this related to IO not computation which might has different impact on the benchmark.
And another question that I could not get the answer in dart.dev website. When compiling dart code to AOT is it going to compile the code to native cpu instructions for instance if I say
i = i + 1;
will be on x86 or similar
add i, 1
php
dart
benchmarking
0 Answers
Your Answer