tests/benchmark: make benchmark cases... bigger

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: Iabd307b475f6568cff4d1ae6e5ae56ef6a6a6964
This commit is contained in:
raf 2026-02-23 02:24:10 +03:00
commit 3347699a8c
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF
3 changed files with 267 additions and 30 deletions

View file

@ -1,31 +1,75 @@
let
# Recursive fibonacci (not memoized)
# Recursive factorial
factorial = n:
if n <= 1
then 1
else n * factorial (n - 1);
# Fibonacci sequence generator
fib = n:
if n <= 1
then n
else fib (n - 1) + fib (n - 2);
# List operations
numbers = [1 2 3 4 5 6 7 8 9 10];
doubled = builtins.map (x: x * 2) numbers;
# List concatenation test
range = start: end:
if start >= end
then []
else [start] ++ range (start + 1) end;
# Attrset operations
# Curried function application
add = x: y: x + y;
add5 = add 5;
# Complex computation
compute = x: y: let
a = x * 2;
b = y + 10;
c = a * b;
in
c / 2;
# Data structures
numbers = range 1 11;
# Nested attribute operations
base = {
a = 1;
b = 2;
c = 3;
config = {
enable = true;
value = 42;
};
data = {
items = [1 2 3];
};
};
extended =
base
// {
d = 4;
e = 5;
config =
base.config
// {
extra = "test";
multiplied = base.config.value * 2;
};
computed = base.config.value + 100;
};
# String operations
greeting = "Hello";
message = "${greeting}, World!";
# Recursive attrset with selections
recursive = rec {
x = 10;
y = x * 2;
z = y + x;
result = z * 3;
final = result + x;
};
in {
fibonacci_10 = fib 10;
inherit doubled extended message;
fact5 = factorial 5;
fib7 = fib 7;
sum15 = add5 10;
computed = compute 10 20;
inherit numbers extended;
deepValue = extended.config.multiplied;
recursiveResult = recursive.result;
recursiveFinal = recursive.final;
}