The Dart Speed
The speed of a programming language is important, even if I rarely need it. I’m happy if the language I use is fast. Although Dart is not the fastest language on the market, I appreciate its cool and clean syntax
I think everyone knows that Rust will be the fastest. But in my speed test
Benchmark
Thebenchmark evaluates the performance
How the benchmark was run:
I coded a small PowerShell script to run each program 10 times and give me the time for each execution, also calculating the average execution time
System Hardware: Processor: AMD Ryzen 7 4800H with Radeon Graphics 2.90 GHz Installed RAM: 16,0 GB (15,4 GB usable) System: Type 64-bit operating system, x64-based processor Windows: Windows 11 Home, Version 23H2
DISCLAIMER: THIS IS NOT A PROFESSIONAL BENCHMARK, IT IS ONLY TO GIVE AN INDICATION OF THE SPEED.
This is the PowerShell script:
# Prompting the user for the command to execute
$command = Read-Host "Enter the command to execute (e.g., 'py main.py')"
# Initializing total time variable
$totalTime = 0
# Running the command 10 times and calculating the total time
for ($i = 1; $i -lt 11; $i++) {
$executionTime = Measure-Command { Invoke-Expression "& $command" }
$totalTime += $executionTime.TotalMilliseconds
Write-Host "Execution $i Time: $($executionTime.TotalMilliseconds) milliseconds"
}
# Calculating average time
$averageTime = $totalTime / 10
Write-Host "Average Execution Time: $averageTime milliseconds"
Dart
领英推荐
JavaScript
Rust
As you can see, it is the same code, just translated between languages.
Results
Average: 9940.12497 ms Compared to Dart: 159 % slower Compared to Rust: 138.67 % slower
Average: 6221.07265 ms Compared to JavaScript:?159 % faster Compared to Rust: 86.79 % slower
Average: 71.67717 ms Compared to JavaScript: 138.67 % faster Compared to Dart: 86.79 % faster
Conclusion
If you just look at JavaScript and Dart, Dart looks like a fast language. Add Rust to the mix and you can see just how fast it can be. As a little motivation to all JavaScript developers, I could not include Python in this benchmark because the run never finished.