Skip to content

Benchmarks

Austin Blass edited this page Apr 9, 2025 · 1 revision

Benchmark Results

Benchmark Execution Time (seconds) Compilation Time (ms)
Basic Arithmetic 0.000664 60.670
String Operations 0.000708 33.638
Conditional Logic 0.000589 41.184
Loop Performance 0.000898 76.810
Function Call Overhead 0.000723 80.110
Dictionary Operations 0.000562 29.889
Complex Conditional Logic 0.000386 33.726
Function Recursion 0.000979 79.838
String Manipulation 0.000484 25.931
Nested Loops 0.000936 28.347

Raw Results

# Benchmark 1: Basic Arithmetic
a = 5
b = 3
c = a + b
return c # Expected 8

# RESULT: 0.0006635189056396484 seconds for execution, 60.6698ms compilation


# Benchmark 2: String Operations
let str1 = "Hello";
let str2 = " World";
let ret = str1 + str2
return ret  # Expected: "Hello World"

# RESULT: 0.0007078647613525391 seconds for execution, 33.638ms compilation


# Benchmark 3: Conditional Logic
let test_value = 10;
if test_value > 5 {
  return "Greater"
}
else {
  ret = "Lesser or Equal"
  return ret
}  # Expected: "Greater"

# RESULT: 0.0005893707275390625 seconds for execution, 41.1843ms compilation


# Benchmark 4: Loop Performance
let sum = 0;
let i = 0;
while check = if i < 100 {
  sum = sum + i;
  i = i + 1
  check = if i < 100
}
return sum  # Expected: 4950

# RESULT: 0.0008976459503173828 seconds for execution, 76.8097ms compilation


# Benchmark 5: Function Call Overhead
def add -> int (x:int, y:int) {
  ret = x + y
  return ret
}

let start_value = 5;
let result = 0;
let j = 0;
while check = if j < 100 {
  result = add(result, start_value);
  j = j + 1
  check = if j < 100
}
return result  # Expected: 500

# RESULT: 0.0007231235504150391 seconds for execution, 80.1099ms compilation


# BENCHMARK 6: Dictionary Operations
let dict = {1: "one", 2: "two", 3: "three", 4: "four"};
let keys = [1, 2, 3, 4];
let concatenated = "";
let k = 0;
while check = if k < 4 {
  indexed_val = keys.k
  concatenated = concatenated + dict.indexed_val
  k = k + 1
  check = if k < 4
}
return concatenated 

# RESULT: 0.0005624294281005859 seconds for execution, 29.8888ms compilation


# Benchmark 7: Complex Conditional Logic
let val = 15;
if val > 20 {
  return "A"
}
elif val > 10 {
  if val % 2 == 0 {
    return "B-Even"
  }
  else {
    return "B-Odd"
  }
}
else {
  return "C"
}  # Expected: "B-Odd"

# RESULT: 0.0003864765167236328 seconds for execution, 33.7264ms compilation


# Benchmark 8: Function Recursion
def factorial -> int (n: int) {
  if n <= 1 {
    return 1
  }
  else {
    new_n = n - 1
    old_n = n
    !n
    factorial_ret: int = factorial(new_n)
    ret = old_n * factorial_ret
    return ret
  }
  return -1
}
ret = factorial(5)
return ret  # Expected: 120

# RESULT: 0.000978708267211914 seconds for execution, 79.8377ms compilation


# Benchmark 9: String Manipulation
prototype print "C:\Users\austi\PycharmProjects\Stream JSON Compiler\test_env\builtins\os\print.py" -> int (val:str)

let original = "benchmark";
let modified = "";
let m = 0;
length:int = original $
while check = if m < length {
  even = m % 2
  if even == 0 {
    modified = modified + original.m
  }
  m = m + 1
  check = if m < length
}
return modified  # Expected: "bnhak"

# RESULT: 0.0004837512969970703 seconds for execution, 25.9312ms compilation


# Benchmark 10: Nested Loops
let grid_size = 5;
let grid_sum = 0;
let row = 0;
while check = if row < grid_size {
  let col = 0;
  while check = if col < grid_size {
    grid_sum = row * col + grid_sum;
    col = col + 1
    check = if col < grid_size
  }
  row = row + 1
  check = if row < grid_size
}
return grid_sum  # Expected: 100

# RESULT: 0.0009362697601318359 seconds for execution, 28.3465ms compilation

Clone this wiki locally