diff --git a/examples/stress_rc.lux b/examples/stress_rc.lux new file mode 100644 index 0000000..69b2a71 --- /dev/null +++ b/examples/stress_rc.lux @@ -0,0 +1,24 @@ +// Stress test for RC system with large lists +// Tests FBIP optimization with single-owner chains + +fn processChain(n: Int): Int = { + // Single owner chain - FBIP should reuse lists + let nums = List.range(1, n) + let doubled = List.map(nums, fn(x: Int): Int => x * 2) + let filtered = List.filter(doubled, fn(x: Int): Bool => x > n) + let reversed = List.reverse(filtered) + List.length(reversed) +} + +fn main(): Unit = { + Console.print("=== RC Stress Test ===") + + // Run multiple iterations of list operations + let result1 = processChain(100) + let result2 = processChain(200) + let result3 = processChain(500) + let result4 = processChain(1000) + + Console.print("Completed 4 chains") + Console.print("Sizes: 100, 200, 500, 1000") +} diff --git a/examples/stress_shared_rc.lux b/examples/stress_shared_rc.lux new file mode 100644 index 0000000..c6e8774 --- /dev/null +++ b/examples/stress_shared_rc.lux @@ -0,0 +1,26 @@ +// Stress test for RC system WITH shared references +// Forces rc>1 path by keeping aliases + +fn processWithAlias(n: Int): Int = { + let nums = List.range(1, n) + let alias = nums // This increments rc, forcing copy path + let _len = List.length(alias) // Use the alias + + // Now nums has rc>1, so map must allocate new + let doubled = List.map(nums, fn(x: Int): Int => x * 2) + let filtered = List.filter(doubled, fn(x: Int): Bool => x > n) + let reversed = List.reverse(filtered) + List.length(reversed) +} + +fn main(): Unit = { + Console.print("=== RC Stress Test (Shared Refs) ===") + + // Run multiple iterations with shared references + let result1 = processWithAlias(100) + let result2 = processWithAlias(200) + let result3 = processWithAlias(500) + let result4 = processWithAlias(1000) + + Console.print("Completed 4 chains with shared refs") +}