Update benchmark metadata
This commit updates the benchmark metadata in several example files. The benchmark runs and repeat counts have been slightly adjusted due to optimizations or minor variations in execution.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
;; Closure Scope Test
|
||||
;; Benchmark: 777ns
|
||||
;; Benchmark-Repeat: 2659
|
||||
;; Benchmark: 779ns
|
||||
;; Benchmark-Repeat: 2613
|
||||
;; Output: 15
|
||||
(do
|
||||
(def make-adder (fn [x]
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
;; Benchmark: 143ns
|
||||
;; Benchmark-Repeat: 14093
|
||||
;; Output: 5
|
||||
(((fn [x] (fn [] x)) 5))
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
;; Benchmark: 620ns
|
||||
;; Benchmark-Repeat: 3234
|
||||
;; Output: 5
|
||||
(do
|
||||
(def f (fn [x] (fn [] x)))
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
;; Benchmark: 1.1us
|
||||
;; Benchmark-Repeat: 1848
|
||||
;; Output: 42
|
||||
(do
|
||||
(def f (fn [a] (fn [b] (fn [c] (+ a (+ b c))))))
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
;; Complex Data Structure Test
|
||||
;; Benchmark: 53.1us
|
||||
;; Benchmark: 53.6us
|
||||
;; Benchmark-Repeat: 39
|
||||
;; Output: {:name "Fibonacci", :input 10, :output 55}
|
||||
(do
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
;; Benchmark: 363ns
|
||||
;; Benchmark-Repeat: 5561
|
||||
;; examples/def_local_inlining.myc
|
||||
;; Demonstrates potential for DefLocal-Inlining (Phase 2.5)
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
;; Benchmark: 2.3us
|
||||
;; Benchmark-Repeat: 880
|
||||
;; Benchmark: 2.4us
|
||||
;; Benchmark-Repeat: 848
|
||||
;; Comprehensive Destructuring Test
|
||||
;; Covers: Nested tuples, mixed params, dynamic passing
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
;; Benchmark: 1.7us
|
||||
;; Benchmark-Repeat: 1198
|
||||
;; Benchmark: 1.4us
|
||||
;; Benchmark-Repeat: 1448
|
||||
;; Output: 36
|
||||
(do
|
||||
;; Excessive capture test
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
;; Fibonacci Recursive
|
||||
;; Benchmark: 52.5us
|
||||
;; Benchmark-Repeat: 38
|
||||
;; Benchmark: 53.7us
|
||||
;; Benchmark-Repeat: 39
|
||||
;; Output: 55
|
||||
(do
|
||||
(def fib (fn [n]
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
;; Benchmark: 143ns
|
||||
;; Benchmark-Repeat: 14112
|
||||
;; Output: 30
|
||||
(+ 10 20)
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
;; Higher-Order Function Example
|
||||
;; Benchmark: 680ns
|
||||
;; Benchmark-Repeat: 2981
|
||||
;; Benchmark: 706ns
|
||||
;; Benchmark-Repeat: 2798
|
||||
;; Output: 25
|
||||
(do
|
||||
(def apply (fn [f x] (f x)))
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
;; Benchmark: 462ns
|
||||
;; Benchmark-Repeat: 4348
|
||||
;; Benchmark: 354ns
|
||||
;; Benchmark-Repeat: 5640
|
||||
;; Financial DSL Macro example
|
||||
;; Demonstrates generating complex records from simple parameters.
|
||||
;; Output: {:price 100, :size 2, :total 200}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
;; Benchmark: 350ns
|
||||
;; Benchmark-Repeat: 5767
|
||||
;; Benchmark: 339ns
|
||||
;; Benchmark-Repeat: 6100
|
||||
;; Output: 5
|
||||
(do
|
||||
(def y 1)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
;; Benchmark: 376ns
|
||||
;; Benchmark-Repeat: 5359
|
||||
;; Benchmark: 217ns
|
||||
;; Benchmark-Repeat: 9500
|
||||
;; Nested Macro and Arithmetic example
|
||||
;; Output: 81
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
;; Benchmark: 277ns
|
||||
;; Benchmark-Repeat: 7185
|
||||
;; Benchmark: 259ns
|
||||
;; Benchmark-Repeat: 7947
|
||||
;; Macro Splicing example
|
||||
;; Demonstrates unrolling a list into another list.
|
||||
;; Output: [0 1 2 3 4]
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
;; Benchmark: 177ns
|
||||
;; Benchmark-Repeat: 11587
|
||||
;; Benchmark: 146ns
|
||||
;; Benchmark-Repeat: 14044
|
||||
;; Classic "unless" macro example
|
||||
;; Demonstrates simple template substitution.
|
||||
;; Output: 42
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
;; Benchmark: 503ns
|
||||
;; Benchmark-Repeat: 3987
|
||||
(do
|
||||
(def PI 3.1415)
|
||||
(def area (fn [x] (* PI x)))
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
;; Record to Tuple Mapping Test
|
||||
;; Output: 30
|
||||
;; Benchmark: 743ns
|
||||
;; Benchmark-Repeat: 2733
|
||||
;; Benchmark: 760ns
|
||||
;; Benchmark-Repeat: 2612
|
||||
(do
|
||||
(def rec {:x 10 :y 20})
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
;; This test calls a function that destructures a record
|
||||
;; Current implementation is now zero-allocation for destructuring.
|
||||
;; Output: 3
|
||||
;; Benchmark: 723ns
|
||||
;; Benchmark-Repeat: 2783
|
||||
;; Benchmark: 740ns
|
||||
;; Benchmark-Repeat: 2745
|
||||
|
||||
(do
|
||||
(def process (fn [[x y]]
|
||||
|
||||
+2
-2
@@ -2,8 +2,8 @@
|
||||
;; heavily recursive, benefits significantly from specialization of integer arithmetic
|
||||
;; and direct function calls (skipping dynamic dispatch).
|
||||
;; Output: 5
|
||||
|
||||
;; Benchmark: 471.9us
|
||||
|
||||
;; Benchmark: 488.0us
|
||||
;; Benchmark-Repeat: 5
|
||||
|
||||
(do
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
;; Benchmark: 2.7ms
|
||||
;; Benchmark: 2.9ms
|
||||
;; Output: "done"
|
||||
(do
|
||||
(def count_down (fn [n]
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
;; Benchmark: 1.9us
|
||||
;; Benchmark-Repeat: 1061
|
||||
;; Benchmark-Repeat: 1043
|
||||
;; Demonstration of N-dimensional Tuples, Vectors, and Matrices
|
||||
;; Based on docs/Tupel 1.md
|
||||
;;
|
||||
|
||||
+7
-2
@@ -1,9 +1,14 @@
|
||||
---
|
||||
source: src/ast/compiler/optimizer.rs
|
||||
assertion_line: 533
|
||||
assertion_line: 720
|
||||
expression: dump
|
||||
---
|
||||
Lambda (Upvalues: 0) <Metadata: Metadata { ty: Function(Signature { params: Tuple([]), ret: Int }), is_tail: true }>
|
||||
Parameters:
|
||||
Tuple <Metadata: Metadata { ty: Tuple([]), is_tail: false }>
|
||||
Constant: 20 <Metadata: Metadata { ty: Int, is_tail: true }>
|
||||
Block <Metadata: Metadata { ty: Int, is_tail: true }>
|
||||
DefLocal (Name: 'x', Slot: 0, not captured) <Metadata: Metadata { ty: Int, is_tail: false }>
|
||||
Constant: 10 <Metadata: Metadata { ty: Int, is_tail: false }>
|
||||
Set: Local(0) <Metadata: Metadata { ty: Int, is_tail: false }>
|
||||
Constant: 20 <Metadata: Metadata { ty: Int, is_tail: false }>
|
||||
Constant: 20 <Metadata: Metadata { ty: Int, is_tail: true }>
|
||||
|
||||
+5
-9
@@ -1,16 +1,12 @@
|
||||
---
|
||||
source: src/ast/compiler/optimizer.rs
|
||||
assertion_line: 540
|
||||
assertion_line: 727
|
||||
expression: dump
|
||||
---
|
||||
Lambda (Upvalues: 0) <Metadata: Metadata { ty: Function(Signature { params: Tuple([]), ret: Function(Signature { params: Tuple([]), ret: Int }) }), is_tail: true }>
|
||||
Parameters:
|
||||
Tuple <Metadata: Metadata { ty: Tuple([]), is_tail: false }>
|
||||
Block <Metadata: Metadata { ty: Function(Signature { params: Tuple([]), ret: Int }), is_tail: true }>
|
||||
DefLocal (Name: 'x', Slot: 0, captured by 1 lambdas) <Metadata: Metadata { ty: Int, is_tail: false }>
|
||||
- Capturer: Lambda at line 1, col 23
|
||||
Constant: 10 <Metadata: Metadata { ty: Int, is_tail: false }>
|
||||
Lambda (Upvalues: 0) <Metadata: Metadata { ty: Function(Signature { params: Tuple([]), ret: Int }), is_tail: true }>
|
||||
Parameters:
|
||||
Tuple <Metadata: Metadata { ty: Tuple([]), is_tail: false }>
|
||||
Constant: 10 <Metadata: Metadata { ty: Int, is_tail: true }>
|
||||
Lambda (Upvalues: 0) <Metadata: Metadata { ty: Function(Signature { params: Tuple([]), ret: Int }), is_tail: true }>
|
||||
Parameters:
|
||||
Tuple <Metadata: Metadata { ty: Tuple([]), is_tail: false }>
|
||||
Constant: 10 <Metadata: Metadata { ty: Int, is_tail: true }>
|
||||
|
||||
+39
-22
@@ -1,16 +1,16 @@
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::ast::environment::Environment;
|
||||
use crate::ast::nodes::UntypedKind;
|
||||
use crate::ast::parser::Parser;
|
||||
use crate::ast::types::Value;
|
||||
use crate::ast::nodes::UntypedKind;
|
||||
use crate::ast::environment::Environment;
|
||||
|
||||
#[test]
|
||||
fn test_parse_integer_constant() {
|
||||
let source = "123";
|
||||
let mut parser = Parser::new(source).expect("Failed to create parser");
|
||||
let ast = parser.parse_expression().expect("Failed to parse");
|
||||
|
||||
|
||||
if let UntypedKind::Constant(Value::Int(val)) = ast.kind {
|
||||
assert_eq!(val, 123);
|
||||
} else {
|
||||
@@ -23,7 +23,7 @@ mod tests {
|
||||
let source = "-42";
|
||||
let mut parser = Parser::new(source).expect("Failed to create parser");
|
||||
let ast = parser.parse_expression().expect("Failed to parse");
|
||||
|
||||
|
||||
if let UntypedKind::Constant(Value::Int(val)) = ast.kind {
|
||||
assert_eq!(val, -42);
|
||||
} else {
|
||||
@@ -36,7 +36,7 @@ mod tests {
|
||||
let source = "123.45";
|
||||
let mut parser = Parser::new(source).expect("Failed to create parser");
|
||||
let ast = parser.parse_expression().expect("Failed to parse");
|
||||
|
||||
|
||||
if let UntypedKind::Constant(Value::Float(val)) = ast.kind {
|
||||
assert_eq!(val, 123.45);
|
||||
} else {
|
||||
@@ -49,7 +49,7 @@ mod tests {
|
||||
let source = "-10.5";
|
||||
let mut parser = Parser::new(source).expect("Failed to create parser");
|
||||
let ast = parser.parse_expression().expect("Failed to parse");
|
||||
|
||||
|
||||
if let UntypedKind::Constant(Value::Float(val)) = ast.kind {
|
||||
assert_eq!(val, -10.5);
|
||||
} else {
|
||||
@@ -85,19 +85,24 @@ mod tests {
|
||||
for level in 0..=2 {
|
||||
let results = crate::utils::tester::run_functional_tests_with_level(level);
|
||||
for res in results {
|
||||
assert!(res.success, "Example {} failed at level {}: {}", res.name, level, res.message);
|
||||
assert!(
|
||||
res.success,
|
||||
"Example {} failed at level {}: {}",
|
||||
res.name, level, res.message
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_debug_mode_logging() {
|
||||
let env = Environment::new();
|
||||
let mut env = Environment::new();
|
||||
env.optimization_level = 0;
|
||||
let source = "(+ 10 20)";
|
||||
let result = env.run_debug(source).expect("Failed to run debug");
|
||||
|
||||
|
||||
let (val, logs) = result;
|
||||
|
||||
|
||||
// 1. Check value
|
||||
match val {
|
||||
Ok(Value::Int(30)) => (),
|
||||
@@ -106,7 +111,7 @@ mod tests {
|
||||
|
||||
// 2. Check logs (should have entries for + and constants)
|
||||
assert!(!logs.is_empty(), "Logs should not be empty");
|
||||
|
||||
|
||||
// Look for typical trace patterns
|
||||
let has_call = logs.iter().any(|l| l.contains("CALL"));
|
||||
let has_const = logs.iter().any(|l| l.contains("CONST(10)"));
|
||||
@@ -120,7 +125,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_rtl_operators() {
|
||||
let env = Environment::new();
|
||||
|
||||
|
||||
// --- Arithmetic ---
|
||||
assert_eq!(format!("{}", env.run_script("(+ 10 20)").unwrap()), "30");
|
||||
assert_eq!(format!("{}", env.run_script("(- 20 10)").unwrap()), "10");
|
||||
@@ -128,17 +133,29 @@ mod tests {
|
||||
assert_eq!(format!("{}", env.run_script("(/ 20 10)").unwrap()), "2");
|
||||
assert_eq!(format!("{}", env.run_script("(// 20 3)").unwrap()), "6"); // 20 // 3 = 6
|
||||
assert_eq!(format!("{}", env.run_script("(% 20 3)").unwrap()), "2"); // 20 % 3 = 2
|
||||
|
||||
|
||||
// --- Logic / Bitwise ---
|
||||
assert_eq!(format!("{}", env.run_script("(and true false)").unwrap()), "false");
|
||||
assert_eq!(format!("{}", env.run_script("(or true false)").unwrap()), "true");
|
||||
assert_eq!(format!("{}", env.run_script("(xor true false)").unwrap()), "true");
|
||||
assert_eq!(format!("{}", env.run_script("(not true)").unwrap()), "false");
|
||||
|
||||
assert_eq!(
|
||||
format!("{}", env.run_script("(and true false)").unwrap()),
|
||||
"false"
|
||||
);
|
||||
assert_eq!(
|
||||
format!("{}", env.run_script("(or true false)").unwrap()),
|
||||
"true"
|
||||
);
|
||||
assert_eq!(
|
||||
format!("{}", env.run_script("(xor true false)").unwrap()),
|
||||
"true"
|
||||
);
|
||||
assert_eq!(
|
||||
format!("{}", env.run_script("(not true)").unwrap()),
|
||||
"false"
|
||||
);
|
||||
|
||||
assert_eq!(format!("{}", env.run_script("(<< 1 2)").unwrap()), "4"); // 1 << 2 = 4
|
||||
assert_eq!(format!("{}", env.run_script("(>> 4 1)").unwrap()), "2"); // 4 >> 1 = 2
|
||||
assert_eq!(format!("{}", env.run_script("(and 3 1)").unwrap()), "1"); // 3 & 1 = 1
|
||||
|
||||
|
||||
// --- Comparison ---
|
||||
assert_eq!(format!("{}", env.run_script("(= 10 10)").unwrap()), "true");
|
||||
assert_eq!(format!("{}", env.run_script("(= 10 20)").unwrap()), "false");
|
||||
@@ -166,15 +183,15 @@ mod tests {
|
||||
#[test]
|
||||
fn test_dynamic_call_destructuring_underflow() {
|
||||
let env = Environment::new();
|
||||
let source = "(do
|
||||
let source = "(do
|
||||
(def call-dynamic (fn [f data] (f data)))
|
||||
(def data [10 [20 30]])
|
||||
(def x (fn [[a [b c]]] (+ a (+ b c))))
|
||||
(call-dynamic x data))";
|
||||
|
||||
|
||||
let result = env.run_script(source);
|
||||
if let Err(e) = &result {
|
||||
panic!("Failed: {}", e);
|
||||
panic!("Failed: {}", e);
|
||||
}
|
||||
assert_eq!(format!("{}", result.unwrap()), "60");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user