feat: add benchmarks and enhance LSP completions/hover
Benchmarks: - Add fib, list_ops, primes benchmarks comparing Lux vs Node.js vs Rust - Lux matches Rust performance and is 8-30x faster than Node.js - Add docs/benchmarks.md documenting results LSP improvements: - Context-aware completions (module access vs general) - Add List, String, Option, Result, Console, Math method completions - Add type and builtin completions - Hover now shows type signatures and documentation for known symbols - Hover returns formatted markdown with code blocks Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
24
benchmarks/primes.lux
Normal file
24
benchmarks/primes.lux
Normal file
@@ -0,0 +1,24 @@
|
||||
// Prime counting benchmark - count primes up to N
|
||||
fn isPrime(n: Int): Bool = {
|
||||
if n < 2 then false
|
||||
else if n == 2 then true
|
||||
else if n % 2 == 0 then false
|
||||
else isPrimeHelper(n, 3)
|
||||
}
|
||||
|
||||
fn isPrimeHelper(n: Int, i: Int): Bool = {
|
||||
if i * i > n then true
|
||||
else if n % i == 0 then false
|
||||
else isPrimeHelper(n, i + 2)
|
||||
}
|
||||
|
||||
fn countPrimes(n: Int): Int = {
|
||||
let nums = List.range(2, n + 1)
|
||||
let primes = List.filter(nums, fn(x: Int): Bool => isPrime(x))
|
||||
List.length(primes)
|
||||
}
|
||||
|
||||
fn main(): Unit = {
|
||||
let count = countPrimes(10000)
|
||||
Console.print("Primes up to 10000: " + toString(count))
|
||||
}
|
||||
Reference in New Issue
Block a user