Programming Language Speed Showdown

Comprehensive performance comparison of some programming languages with runnable benchmark examples.

5 min read
0 views
By Siraj AL Zahran
PerformanceBenchmarkProgrammingSpeedComparison
Programming Language Speed Showdown

The Ultimate Performance Comparison

Ever wondered which programming language is fastest for different tasks? Let's put them to the test with real benchmarks you can run directly here!

Benchmark 1: Fibonacci Sequence

The Classic Performance Test

JavaScript:

javascript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
console.log("JavaScript Fibonacci Benchmark");
 
function fibonacci(n) {
if (n <= 1) return n;
return fibonacci(n - 1) + fibonacci(n - 2);
}
 
// Warm up
fibonacci(10);
 
// Benchmark
const startTime = performance.now();
const result = fibonacci(35);
const endTime = performance.now();
 
console.log(`fib(35) = ${result}`);
console.log(`Execution time: ${(endTime - startTime).toFixed(2)}ms`);
console.log(`JavaScript benchmark completed!`);
Terminal
Terminal Output
Click the Run button to execute the code...

Python:

python
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import time
 
print("Python Fibonacci Benchmark")
 
def fibonacci(n):
if n <= 1:
return n
return fibonacci(n-1) + fibonacci(n-2)
 
# Warm up
fibonacci(10)
 
# Benchmark
start_time = time.time()
result = fibonacci(35)
end_time = time.time()
 
print(f"fib(35) = {result}")
print(f"Execution time: {(end_time - start_time) * 1000:.2f}ms")
print("Python benchmark completed!")
Terminal
Terminal Output
Click the Run button to execute the code...

C++:

cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <iostream>
#include <chrono>
 
using namespace std;
using namespace std::chrono;
 
int fibonacci(int n) {
if (n <= 1) return n;
return fibonacci(n-1) + fibonacci(n-2);
}
 
int main() {
cout << "C++ Fibonacci Benchmark" << endl;
 
// Warm up
fibonacci(10);
 
auto start = high_resolution_clock::now();
int result = fibonacci(35);
auto end = high_resolution_clock::now();
 
auto duration = duration_cast<milliseconds>(end - start);
 
cout << "fib(35) = " << result << endl;
cout << "Execution time: " << duration.count() << "ms" << endl;
cout << "C++ benchmark completed!" << endl;
 
return 0;
}
Terminal
Terminal Output
Click the Run button to execute the code...

Java:

java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
public class Main {
public static int fibonacci(int n) {
if (n <= 1) return n;
return fibonacci(n-1) + fibonacci(n-2);
}
 
public static void main(String[] args) {
System.out.println("Java Fibonacci Benchmark");
 
// Warm up
fibonacci(10);
 
long startTime = System.currentTimeMillis();
int result = fibonacci(35);
long endTime = System.currentTimeMillis();
 
System.out.println("fib(35) = " + result);
System.out.println("Execution time: " + (endTime - startTime) + "ms");
System.out.println("Java benchmark completed!");
}
}
Terminal
Terminal Output
Click the Run button to execute the code...

Go:

go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package main
 
import (
"fmt"
"time"
)
 
func fibonacci(n int) int {
if n <= 1 {
return n
}
return fibonacci(n-1) + fibonacci(n-2)
}
 
func main() {
fmt.Println("Go Fibonacci Benchmark")
 
// Warm up
fibonacci(10)
 
startTime := time.Now()
result := fibonacci(35)
endTime := time.Now()
 
duration := endTime.Sub(startTime)
 
fmt.Printf("fib(35) = %d\n", result)
fmt.Printf("Execution time: %.2fms\n", float64(duration.Microseconds())/1000)
fmt.Println("Go benchmark completed!")
}
Terminal
Terminal Output
Click the Run button to execute the code...

Rust:

rust
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use std::time::Instant;
 
fn fibonacci(n: i32) -> i32 {
if n <= 1 {
return n;
}
fibonacci(n - 1) + fibonacci(n - 2)
}
 
fn main() {
println!("Rust Fibonacci Benchmark");
 
// Warm up
fibonacci(10);
 
let start = Instant::now();
let result = fibonacci(35);
let duration = start.elapsed();
 
println!("fib(35) = {}", result);
println!("Execution time: {:.2}ms", duration.as_secs_f64() * 1000.0);
println!("Rust benchmark completed!");
}
Terminal
Terminal Output
Click the Run button to execute the code...

Benchmark 2: Array/List Operations

Testing Memory and Loop Performance

JavaScript:

javascript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
console.log("JavaScript Array Operations Benchmark");
 
function benchmarkArrayOperations() {
const size = 100000;
const array = new Array(size);
 
// Fill array
let startTime = performance.now();
for (let i = 0; i < size; i++) {
array[i] = Math.random() * 1000;
}
let endTime = performance.now();
console.log(`Array fill: ${(endTime - startTime).toFixed(2)}ms`);
 
// Map operation
startTime = performance.now();
const doubled = array.map((x) => x * 2);
endTime = performance.now();
console.log(`Array map: ${(endTime - startTime).toFixed(2)}ms`);
 
// Filter operation
startTime = performance.now();
const filtered = array.filter((x) => x > 500);
endTime = performance.now();
console.log(`Array filter: ${(endTime - startTime).toFixed(2)}ms`);
 
// Reduce operation
startTime = performance.now();
const sum = array.reduce((acc, x) => acc + x, 0);
endTime = performance.now();
console.log(`Array reduce: ${(endTime - startTime).toFixed(2)}ms`);
console.log(`Sample sum: ${sum.toFixed(2)}`);
}
 
benchmarkArrayOperations();
console.log("JavaScript array benchmark completed!");
Terminal
Terminal Output
Click the Run button to execute the code...

Python:

python
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import time
import random
 
print("Python List Operations Benchmark")
 
def benchmark_list_operations():
size = 100000
# List creation
start_time = time.time()
numbers = [random.random() * 1000 for _ in range(size)]
end_time = time.time()
print(f"List creation: {(end_time - start_time) * 1000:.2f}ms")
 
# Map operation
start_time = time.time()
doubled = [x * 2 for x in numbers]
end_time = time.time()
print(f"List comprehension (map): {(end_time - start_time) * 1000:.2f}ms")
 
# Filter operation
start_time = time.time()
filtered = [x for x in numbers if x > 500]
end_time = time.time()
print(f"List comprehension (filter): {(end_time - start_time) * 1000:.2f}ms")
 
# Reduce operation
start_time = time.time()
total = sum(numbers)
end_time = time.time()
print(f"Sum reduction: {(end_time - start_time) * 1000:.2f}ms")
print(f"Sample sum: {total:.2f}")
 
benchmark_list_operations()
print("Python list benchmark completed!")
Terminal
Terminal Output
Click the Run button to execute the code...

C++:

cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <numeric>
#include <algorithm>
 
using namespace std;
using namespace std::chrono;
 
void benchmarkVectorOperations() {
const int size = 100000;
vector<double> numbers(size);
 
// Random number generator
random_device rd;
mt19937 gen(rd());
uniform_real_distribution<> dis(0, 1000);
 
// Fill vector
auto start = high_resolution_clock::now();
for (int i = 0; i < size; i++) {
numbers[i] = dis(gen);
}
auto end = high_resolution_clock::now();
cout << "Vector fill: " << duration_cast<milliseconds>(end - start).count() << "ms" << endl;
 
// Transform (map) operation
vector<double> doubled(size);
start = high_resolution_clock::now();
transform(numbers.begin(), numbers.end(), doubled.begin(), [](double x) { return x * 2; });
end = high_resolution_clock::now();
cout << "Vector transform: " << duration_cast<milliseconds>(end - start).count() << "ms" << endl;
 
// Copy if (filter) operation
vector<double> filtered;
start = high_resolution_clock::now();
copy_if(numbers.begin(), numbers.end(), back_inserter(filtered), [](double x) { return x > 500; });
end = high_resolution_clock::now();
cout << "Vector filter: " << duration_cast<milliseconds>(end - start).count() << "ms" << endl;
 
// Accumulate (reduce) operation
start = high_resolution_clock::now();
double total = accumulate(numbers.begin(), numbers.end(), 0.0);
end = high_resolution_clock::now();
cout << "Vector reduce: " << duration_cast<milliseconds>(end - start).count() << "ms" << endl;
cout << "Sample sum: " << total << endl;
}
 
int main() {
cout << "C++ Vector Operations Benchmark" << endl;
benchmarkVectorOperations();
cout << "C++ vector benchmark completed!" << endl;
return 0;
}
Terminal
Terminal Output
Click the Run button to execute the code...

Benchmark 3: String Manipulation

Testing String Processing Speed

JavaScript:

javascript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
console.log("JavaScript String Manipulation Benchmark");
 
function benchmarkStringOperations() {
const baseString = "Hello, World! ";
const iterations = 10000;
 
// String concatenation
let startTime = performance.now();
let result = "";
for (let i = 0; i < iterations; i++) {
result += baseString + i;
}
let endTime = performance.now();
console.log(`String concatenation: ${(endTime - startTime).toFixed(2)}ms`);
 
// String methods
const testString = "The Quick Brown Fox Jumps Over The Lazy Dog";
startTime = performance.now();
const upper = testString.toUpperCase();
const lower = testString.toLowerCase();
const replaced = testString.replace(/The/g, "A");
const split = testString.split(" ");
endTime = performance.now();
console.log(`String methods: ${(endTime - startTime).toFixed(2)}ms`);
}
 
benchmarkStringOperations();
console.log("JavaScript string benchmark completed!");
Terminal
Terminal Output
Click the Run button to execute the code...

Python:

python
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import time
 
print("Python String Manipulation Benchmark")
 
def benchmark_string_operations():
base_string = "Hello, World! "
iterations = 10000
 
# String concatenation
start_time = time.time()
result = ""
for i in range(iterations):
result += base_string + str(i)
end_time = time.time()
print(f"String concatenation: {(end_time - start_time) * 1000:.2f}ms")
 
# String methods
test_string = "The Quick Brown Fox Jumps Over The Lazy Dog"
start_time = time.time()
upper = test_string.upper()
lower = test_string.lower()
replaced = test_string.replace("The", "A")
split = test_string.split(" ")
end_time = time.time()
print(f"String methods: {(end_time - start_time) * 1000:.2f}ms")
 
benchmark_string_operations()
print("Python string benchmark completed!")
Terminal
Terminal Output
Click the Run button to execute the code...

Benchmark 4: Object/Struct Operations

Testing Data Structure Performance

JavaScript:

javascript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
console.log("JavaScript Object Operations Benchmark");
 
function benchmarkObjectOperations() {
const iterations = 100000;
 
// Object creation and access
let startTime = performance.now();
const objects = [];
for (let i = 0; i < iterations; i++) {
objects.push({
id: i,
name: `Object${i}`,
value: Math.random() * 1000,
active: i % 2 === 0,
});
}
let endTime = performance.now();
console.log(`Object creation: ${(endTime - startTime).toFixed(2)}ms`);
 
// Object property access
startTime = performance.now();
let total = 0;
objects.forEach((obj) => {
total += obj.value;
if (obj.active) {
total += obj.id;
}
});
endTime = performance.now();
console.log(`Object access: ${(endTime - startTime).toFixed(2)}ms`);
console.log(`Sample total: ${total.toFixed(2)}`);
}
 
benchmarkObjectOperations();
console.log("JavaScript object benchmark completed!");
Terminal
Terminal Output
Click the Run button to execute the code...

Python:

python
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import time
import random
from dataclasses import dataclass
from typing import List
 
print("Python Data Class Operations Benchmark")
 
@dataclass
class DataObject:
id: int
name: str
value: float
active: bool
 
def benchmark_dataclass_operations():
iterations = 100000
 
# Object creation
start_time = time.time()
objects: List[DataObject] = []
for i in range(iterations):
objects.append(DataObject(
id=i,
name=f"Object{i}",
value=random.random() * 1000,
active=i % 2 == 0
))
end_time = time.time()
print(f"DataClass creation: {(end_time - start_time) * 1000:.2f}ms")
 
# Object access
start_time = time.time()
total = 0.0
for obj in objects:
total += obj.value
if obj.active:
total += obj.id
end_time = time.time()
print(f"DataClass access: {(end_time - start_time) * 1000:.2f}ms")
print(f"Sample total: {total:.2f}")
 
benchmark_dataclass_operations()
print("Python dataclass benchmark completed!")
Terminal
Terminal Output
Click the Run button to execute the code...

Quick Performance Summary Test

Run All Quick Benchmarks

JavaScript Quick Summary:

javascript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
console.log("JavaScript Quick Performance Summary");
 
// Fibonacci
function fib(n) {
return n <= 1 ? n : fib(n - 1) + fib(n - 2);
}
 
// Array operations
function arrayTest(size) {
const arr = Array(size)
.fill()
.map((_, i) => i);
return arr
.map((x) => x * 2)
.filter((x) => x > size / 2)
.reduce((a, b) => a + b, 0);
}
 
// Run benchmarks
console.time("Fibonacci 30");
const fibResult = fib(30);
console.timeEnd("Fibonacci 30");
 
console.time("Array Operations 50000");
const arrayResult = arrayTest(50000);
console.timeEnd("Array Operations 50000");
 
console.log(`Fibonacci result: ${fibResult}`);
console.log(`Array result: ${arrayResult}`);
console.log("JavaScript quick benchmark completed!");
Terminal
Terminal Output
Click the Run button to execute the code...

Python Quick Summary:

python
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import time
 
print("Python Quick Performance Summary")
 
def fib(n):
return n if n <= 1 else fib(n-1) + fib(n-2)
 
def list_test(size):
lst = [i for i in range(size)]
return sum(x * 2 for x in lst if x * 2 > size / 2)
 
# Run benchmarks
start = time.time()
fib_result = fib(30)
fib_time = time.time() - start
 
start = time.time()
list_result = list_test(50000)
list_time = time.time() - start
 
print(f"Fibonacci 30: {fib_time * 1000:.2f}ms")
print(f"List operations 50000: {list_time * 1000:.2f}ms")
print(f"Fibonacci result: {fib_result}")
print(f"List result: {list_result}")
print("Python quick benchmark completed!")
Terminal
Terminal Output
Click the Run button to execute the code...

Expected Performance Ranking

Based on typical performance characteristics:

  1. C++/Rust - Native compilation, maximum optimization
  2. Go - Compiled, efficient runtime
  3. Java - JIT compilation, well-optimized
  4. C# - .NET JIT compilation
  5. JavaScript - Modern JIT engines (V8)
  6. Python - Interpreted, but Pyodide provides WASM speed
  7. Ruby/PHP - Interpreted languages

Important Notes

  • Execution Environment: These benchmarks run in different environments (Web Workers, Pyodide, Piston API)
  • Network Latency: Piston API languages include network round-trip time
  • Warm-up: First runs might be slower due to JIT warm-up
  • Browser vs Native: JavaScript/Python run in browser, others run on server

Run Your Own Tests!

Try running these benchmarks to see how each language performs in your specific environment. The results might surprise you!

Pro Tip: Run each benchmark multiple times and average the results for more accurate comparisons.

Happy benchmarking!

More Deep Dives

Claude Code: Agent Teams, MCP Servers & CI/CD Pipelines
20 min read

Claude Code: Agent Teams, MCP Servers & CI/CD Pipelines

Go multi-agent with Claude Code. Master agent teams, build custom MCP integrations, automate with GitHub Actions, and create CI/CD pipelines that code for you.

Claude CodeMCP+5
Feb 25, 2026
Read
Claude Code Remote Control: Continue Terminal Sessions From Your Phone
10 min read

Claude Code Remote Control: Continue Terminal Sessions From Your Phone

Learn how Remote Control lets you continue Claude Code sessions from your phone, tablet, or any browser — while everything runs locally on your machine.

Claude CodeRemote Control+5
Feb 25, 2026
Read
Code to Canvas: Turning Production Code into Editable Figma Designs
16 min read

Code to Canvas: Turning Production Code into Editable Figma Designs

Learn how Claude Code + Figma's MCP server turns your running UI into editable Figma layers — and back. The complete bidirectional design-code workflow.

FigmaClaude Code+5
Feb 25, 2026
Read
Mastering Claude Code: Skills, Memory, Tokens & Power-User Secrets
22 min read

Mastering Claude Code: Skills, Memory, Tokens & Power-User Secrets

Go beyond basics. Master CLAUDE.md context, auto memory, custom skills, hooks, subagents, token optimization, and the workflows that 10x your productivity with Claude Code.

Claude CodeAI+5
Feb 24, 2026
Read
Claude Code: The Agentic Coding Tool That Lives in Your Terminal
14 min read

Claude Code: The Agentic Coding Tool That Lives in Your Terminal

Master Claude Code — Anthropic's AI coding agent. Learn setup, agentic workflows, MCP servers, hooks, CLAUDE.md, and how it compares to Cursor and Copilot.

Claude CodeAI+5
Feb 23, 2026
Read
JSX & Components — ReactJS Series Part 2
12 min read

JSX & Components — ReactJS Series Part 2

Learn how JSX works under the hood, how to create and nest React components, and the rules that make JSX different from HTML.

ReactJavaScript+4
Feb 21, 2026
Read
View All Dives

Explore more content