feat: Prepare for code modularization and cleanup
- Archive old documentation and test files to `docs/archive/` and `local_tests/`. - Remove various temporary and old files from the project root. - Add `nekocode-rust` analysis tool and its output files (`nekocode/`, `.nekocode_sessions/`, `analysis.json`). - Minor updates to `apps/chip8_nyash/chip8_emulator.nyash` and `local_tests` files. This commit cleans up the repository and sets the stage for further code modularization efforts, particularly in the `src/interpreter` and `src/parser` modules, based on recent analysis.
This commit is contained in:
53
local_tests/test_zero_copy_simple.nyash
Normal file
53
local_tests/test_zero_copy_simple.nyash
Normal file
@ -0,0 +1,53 @@
|
||||
// 🧪 Zero-copy Detection Simple Test - Phase 10 Feature Verification
|
||||
// Testing BufferBox.is_shared_with() and share_reference() APIs
|
||||
|
||||
static box Main {
|
||||
init { console }
|
||||
|
||||
main() {
|
||||
me.console = new ConsoleBox()
|
||||
me.console.log("🧪 Phase 10: Zero-copy Detection Test")
|
||||
|
||||
// Test 1: Create two separate buffers (should NOT be shared)
|
||||
me.console.log("\n=== Test 1: Separate buffers ===")
|
||||
local buffer1 = new BufferBox()
|
||||
local buffer2 = new BufferBox()
|
||||
|
||||
buffer1.write("Hello World")
|
||||
buffer2.write("Different Data")
|
||||
|
||||
local is_shared_separate = buffer1.is_shared_with(buffer2)
|
||||
me.console.log("Separate buffers shared: " + is_shared_separate)
|
||||
|
||||
// Test 2: Create shared reference (SHOULD be shared)
|
||||
me.console.log("\n=== Test 2: Shared reference ===")
|
||||
local buffer3 = new BufferBox()
|
||||
buffer3.write("Shared Data Test")
|
||||
|
||||
local shared_buffer = buffer3.share_reference(buffer3)
|
||||
local is_shared_ref = buffer3.is_shared_with(shared_buffer)
|
||||
me.console.log("Shared reference detection: " + is_shared_ref)
|
||||
|
||||
// Test 3: Memory footprint monitoring
|
||||
me.console.log("\n=== Test 3: Memory footprint ===")
|
||||
local memory_size = buffer3.memory_footprint()
|
||||
me.console.log("Buffer3 memory footprint: " + memory_size + " bytes")
|
||||
|
||||
// Test 4: Zero-copy behavior simulation
|
||||
me.console.log("\n=== Test 4: Zero-copy simulation ===")
|
||||
local original_buffer = new BufferBox()
|
||||
original_buffer.write("Large data for zero-copy test")
|
||||
|
||||
local zero_copy_buffer = original_buffer.share_reference(original_buffer)
|
||||
local zero_copy_result = original_buffer.is_shared_with(zero_copy_buffer)
|
||||
|
||||
if (zero_copy_result.toString() == "true") {
|
||||
me.console.log("✅ Zero-copy achieved! Memory sharing successful")
|
||||
} else {
|
||||
me.console.log("❌ Zero-copy failed! Unnecessary data copying detected")
|
||||
}
|
||||
|
||||
me.console.log("\n🎉 Phase 10 Zero-copy API Test Complete!")
|
||||
return "Zero-copy test finished"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user