From 0ed52a811d7daea36465edea3013fbe0e0471f7e Mon Sep 17 00:00:00 2001 From: Michael Schimmel Date: Sun, 22 Feb 2026 01:37:00 +0100 Subject: [PATCH] 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. --- examples/closure.myc | 4 +- examples/closure_cracking.myc | 2 + examples/closure_cracking_named.myc | 2 + examples/currying.myc | 2 + examples/data.myc | 2 +- examples/def_local_inlining.myc | 2 + examples/destructuring.myc | 4 +- examples/extreme_capture.myc | 4 +- examples/fib.myc | 4 +- examples/folding.myc | 2 + examples/hof.myc | 4 +- examples/macro_financial.myc | 4 +- examples/macro_hygiene.myc | 4 +- examples/macro_power.myc | 4 +- examples/macro_splice.myc | 4 +- examples/macro_unless.myc | 4 +- examples/optimizer_purity.myc | 2 + examples/record_to_tuple.myc | 4 +- examples/record_unpack.myc | 4 +- examples/tak.myc | 4 +- examples/tco_test.myc | 2 +- examples/tuples.myc | 2 +- ...timizer__tests__opt_assignment_safety.snap | 9 ++- ...optimizer__tests__opt_lambda_cracking.snap | 14 ++--- src/integration_test.rs | 61 ++++++++++++------- 25 files changed, 92 insertions(+), 62 deletions(-) diff --git a/examples/closure.myc b/examples/closure.myc index f2851a8..4a38f14 100644 --- a/examples/closure.myc +++ b/examples/closure.myc @@ -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] diff --git a/examples/closure_cracking.myc b/examples/closure_cracking.myc index 8edf76c..64b4db2 100644 --- a/examples/closure_cracking.myc +++ b/examples/closure_cracking.myc @@ -1,2 +1,4 @@ +;; Benchmark: 143ns +;; Benchmark-Repeat: 14093 ;; Output: 5 (((fn [x] (fn [] x)) 5)) diff --git a/examples/closure_cracking_named.myc b/examples/closure_cracking_named.myc index 4e95860..61fcae2 100644 --- a/examples/closure_cracking_named.myc +++ b/examples/closure_cracking_named.myc @@ -1,3 +1,5 @@ +;; Benchmark: 620ns +;; Benchmark-Repeat: 3234 ;; Output: 5 (do (def f (fn [x] (fn [] x))) diff --git a/examples/currying.myc b/examples/currying.myc index 1265bab..125e1c3 100644 --- a/examples/currying.myc +++ b/examples/currying.myc @@ -1,3 +1,5 @@ +;; Benchmark: 1.1us +;; Benchmark-Repeat: 1848 ;; Output: 42 (do (def f (fn [a] (fn [b] (fn [c] (+ a (+ b c)))))) diff --git a/examples/data.myc b/examples/data.myc index 2458c01..2cb39c6 100644 --- a/examples/data.myc +++ b/examples/data.myc @@ -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 diff --git a/examples/def_local_inlining.myc b/examples/def_local_inlining.myc index 1779f17..6d1accd 100644 --- a/examples/def_local_inlining.myc +++ b/examples/def_local_inlining.myc @@ -1,3 +1,5 @@ +;; Benchmark: 363ns +;; Benchmark-Repeat: 5561 ;; examples/def_local_inlining.myc ;; Demonstrates potential for DefLocal-Inlining (Phase 2.5) diff --git a/examples/destructuring.myc b/examples/destructuring.myc index de64fa7..55fc643 100644 --- a/examples/destructuring.myc +++ b/examples/destructuring.myc @@ -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 diff --git a/examples/extreme_capture.myc b/examples/extreme_capture.myc index f653655..324dc73 100644 --- a/examples/extreme_capture.myc +++ b/examples/extreme_capture.myc @@ -1,5 +1,5 @@ -;; Benchmark: 1.7us -;; Benchmark-Repeat: 1198 +;; Benchmark: 1.4us +;; Benchmark-Repeat: 1448 ;; Output: 36 (do ;; Excessive capture test diff --git a/examples/fib.myc b/examples/fib.myc index a0f9bc2..c5b3b3f 100644 --- a/examples/fib.myc +++ b/examples/fib.myc @@ -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] diff --git a/examples/folding.myc b/examples/folding.myc index 7ca0f76..6bb12ff 100644 --- a/examples/folding.myc +++ b/examples/folding.myc @@ -1,2 +1,4 @@ +;; Benchmark: 143ns +;; Benchmark-Repeat: 14112 ;; Output: 30 (+ 10 20) diff --git a/examples/hof.myc b/examples/hof.myc index d7676fc..072f005 100644 --- a/examples/hof.myc +++ b/examples/hof.myc @@ -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))) diff --git a/examples/macro_financial.myc b/examples/macro_financial.myc index 768b8d7..3279a70 100644 --- a/examples/macro_financial.myc +++ b/examples/macro_financial.myc @@ -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} diff --git a/examples/macro_hygiene.myc b/examples/macro_hygiene.myc index 5e6715e..ef205fc 100644 --- a/examples/macro_hygiene.myc +++ b/examples/macro_hygiene.myc @@ -1,5 +1,5 @@ -;; Benchmark: 350ns -;; Benchmark-Repeat: 5767 +;; Benchmark: 339ns +;; Benchmark-Repeat: 6100 ;; Output: 5 (do (def y 1) diff --git a/examples/macro_power.myc b/examples/macro_power.myc index 18479dd..4818a35 100644 --- a/examples/macro_power.myc +++ b/examples/macro_power.myc @@ -1,5 +1,5 @@ -;; Benchmark: 376ns -;; Benchmark-Repeat: 5359 +;; Benchmark: 217ns +;; Benchmark-Repeat: 9500 ;; Nested Macro and Arithmetic example ;; Output: 81 diff --git a/examples/macro_splice.myc b/examples/macro_splice.myc index 5369053..0ea70c6 100644 --- a/examples/macro_splice.myc +++ b/examples/macro_splice.myc @@ -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] diff --git a/examples/macro_unless.myc b/examples/macro_unless.myc index 14d98e8..d9fe294 100644 --- a/examples/macro_unless.myc +++ b/examples/macro_unless.myc @@ -1,5 +1,5 @@ -;; Benchmark: 177ns -;; Benchmark-Repeat: 11587 +;; Benchmark: 146ns +;; Benchmark-Repeat: 14044 ;; Classic "unless" macro example ;; Demonstrates simple template substitution. ;; Output: 42 diff --git a/examples/optimizer_purity.myc b/examples/optimizer_purity.myc index 288882e..13fb7d8 100644 --- a/examples/optimizer_purity.myc +++ b/examples/optimizer_purity.myc @@ -1,3 +1,5 @@ +;; Benchmark: 503ns +;; Benchmark-Repeat: 3987 (do (def PI 3.1415) (def area (fn [x] (* PI x))) diff --git a/examples/record_to_tuple.myc b/examples/record_to_tuple.myc index 8b1135a..fd1b2e5 100644 --- a/examples/record_to_tuple.myc +++ b/examples/record_to_tuple.myc @@ -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}) diff --git a/examples/record_unpack.myc b/examples/record_unpack.myc index 19fae1e..11f67e3 100644 --- a/examples/record_unpack.myc +++ b/examples/record_unpack.myc @@ -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]] (+ x y))) diff --git a/examples/tak.myc b/examples/tak.myc index 5ba52e5..d162827 100644 --- a/examples/tak.myc +++ b/examples/tak.myc @@ -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-Repeat: 6 + ;; Benchmark: 488.0us +;; Benchmark-Repeat: 5 (do (def tak (fn [x y z] diff --git a/examples/tco_test.myc b/examples/tco_test.myc index 2ac1006..329524c 100644 --- a/examples/tco_test.myc +++ b/examples/tco_test.myc @@ -1,4 +1,4 @@ -;; Benchmark: 2.7ms +;; Benchmark: 2.9ms ;; Output: "done" (do (def count_down (fn [n] diff --git a/examples/tuples.myc b/examples/tuples.myc index 0e5d1ab..1e4f731 100644 --- a/examples/tuples.myc +++ b/examples/tuples.myc @@ -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 ;; diff --git a/src/ast/compiler/snapshots/myc__ast__compiler__optimizer__tests__opt_assignment_safety.snap b/src/ast/compiler/snapshots/myc__ast__compiler__optimizer__tests__opt_assignment_safety.snap index 49a9adc..fc79742 100644 --- a/src/ast/compiler/snapshots/myc__ast__compiler__optimizer__tests__opt_assignment_safety.snap +++ b/src/ast/compiler/snapshots/myc__ast__compiler__optimizer__tests__opt_assignment_safety.snap @@ -1,9 +1,14 @@ --- source: src/ast/compiler/optimizer.rs -assertion_line: 533 +assertion_line: 720 expression: dump --- Lambda (Upvalues: 0) Parameters: Tuple - Constant: 20 + Block + DefLocal (Name: 'x', Slot: 0, not captured) + Constant: 10 + Set: Local(0) + Constant: 20 + Constant: 20 diff --git a/src/ast/compiler/snapshots/myc__ast__compiler__optimizer__tests__opt_lambda_cracking.snap b/src/ast/compiler/snapshots/myc__ast__compiler__optimizer__tests__opt_lambda_cracking.snap index 9cd7e14..5e6fbbb 100644 --- a/src/ast/compiler/snapshots/myc__ast__compiler__optimizer__tests__opt_lambda_cracking.snap +++ b/src/ast/compiler/snapshots/myc__ast__compiler__optimizer__tests__opt_lambda_cracking.snap @@ -1,16 +1,12 @@ --- source: src/ast/compiler/optimizer.rs -assertion_line: 540 +assertion_line: 727 expression: dump --- Lambda (Upvalues: 0) Parameters: Tuple - Block - DefLocal (Name: 'x', Slot: 0, captured by 1 lambdas) - - Capturer: Lambda at line 1, col 23 - Constant: 10 - Lambda (Upvalues: 0) - Parameters: - Tuple - Constant: 10 + Lambda (Upvalues: 0) + Parameters: + Tuple + Constant: 10 diff --git a/src/integration_test.rs b/src/integration_test.rs index caa64b5..4058f86 100644 --- a/src/integration_test.rs +++ b/src/integration_test.rs @@ -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"); }