Tested the Performance of 10 Programming Languages
And the fastest was ...
🔊 In this video we test the speed of programming languages:
And at the end we created a ranking with Awk.
Watch the video
The video is in Brazilian Portuguese, but you can use subtitles and translate into your language.
Code of Languages
01. SHELL SCRIPT vim sh.sh
for i in {1..1000000};
do
echo -en "${i}Ok\r"
done
- Run:
sh sh.sh
- Test:
time sh sh.sh
02. PHP vim php.php
<?php
for( $i = 0; $i <= 1000000; $i++ ){
echo "{$i}Ok\r";
}
- Run:
php php.php
- Test:
time php php.php
03. JAVASCRIPT vim js.js
for( var i = 0; i <= 1000000; i++ ){
process.stdout.write( i + "Ok\r");
}
- Run:
node js.js
- Test:
time node js.js
04. RUBY vim ruby.rb
for i in 1..1000000 do
print "#{i}Ok\r"
end
- Run:
ruby ruby.rb
- Test:
time ruby ruby.rb
05. PYTHON vim python.py
for i in range(1000001):
print( str(i) + "Ok\r", end='' )
- Run:
python python.py
- Test:
time python python.py
06. JAVA vim java.java
class java {
public static void main ( String args[] ) {
for ( int i = 0; i <= 1000000 ; i++ ){
System.out.print( i + "Ok\r" );
}
}
}
- Run:
javac java.java && java java
- Test:
time java java
07. GO vim go.go
package main
import (
"fmt"
)
func main() {
for i := 0; i <= 1000000; i++{
fmt.Printf("%vOK\r", i)
}
}
- Run:
go build go.go && ./go
- Test:
time ./go
08. C++ vim cpp.cpp
#include <iostream>
int main(){
for (int i = 0; i <= 1000000; i++) {
std::cout << i << "Ok\r";
}
return 0;
}
- Run:
g++ cpp.cpp && ./a.out
- Test:
time ./a.out
09. RUST vim rust.rs
fn main() {
for i in 0..1000001 {
print!("{}Ok\r", i);
}
}
- Run:
rustc rust.rs && ./rust
- Test:
time ./rust
10. C vim c.c
i#include <stdio.h>
int main(){
for (int i = 0; i <= 1000000; i++) {
printf("%iOk\r", i);
}
return 0;
}
- Run:
gcc c.c && ./a.out
- Test:
time ./a.out
Peace!
cpp c python java php ruby go javascript rust shellscript
Comments