Files
hakorune/docs/papers/active/paper-c-unified-revolution/experiments/bench_scalar_loop.nyash
Moe Charm 02d36cc2cb feat: Windows native Egui demo success + Paper C unified strategy
🎉 MAJOR MILESTONE: First successful Windows native Egui application
- Fixed stack overflow in plugin initialization
- Windows Egui demo running with JIT host-bridge
- Complete plugin system validation

📚 Paper C: Unified revolution strategy
- Three-paper approach: MIR13 + BoxCall + Unified
- ChatGPT5's "one representation, two execution" concept
- Complete experimental benchmark planning

🛠️ Technical achievements:
- nyash.exe with Cranelift JIT on Windows
- nyash_egui_plugin.dll (4.39MB) successful build
- VM + JIT + host-bridge integration working
- apps/egui-hello/main.nyash: open→uiLabel→run→close pipeline

🔬 Research foundation:
- docs/papers/active/paper-c-unified-revolution/ complete structure
- Benchmark experiments ready for Load/Store elimination validation
- AI-collaborative development methodology documented

This represents Phase 15 self-hosting technical foundation completion.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-04 12:15:30 +09:00

76 lines
2.3 KiB
Plaintext

// Benchmark 1: スカラ変数ループ性能測定
// 目的: BoxCall最適化でLoad/Store相当の性能を達成することを実証
static box ScalarBench {
console: ConsoleBox
main() {
me.console = new ConsoleBox()
// ウォームアップ
me.warmup()
// 本測定
me.runBenchmark()
// 比較用: 配列経由の間接アクセス
me.runIndirectBenchmark()
}
warmup() {
me.console.log("=== Warming up ===")
local x = 0
loop(x < 1000000) {
x = x + 1
}
}
runBenchmark() {
me.console.log("\n=== Direct Scalar Loop ===")
local x = 0
local iterations = 100000000
local start = new TimeBox()
local startMs = start.now()
// メインループ: BoxCall("get") + BinOp + BoxCall("set")として表現される
loop(x < iterations) {
x = x + 1 // 最適化でレジスタ化されるべき
}
local end = new TimeBox()
local elapsed = end.now() - startMs
me.console.log("Iterations: " + iterations)
me.console.log("Time: " + elapsed + "ms")
me.console.log("ops/sec: " + (iterations / (elapsed / 1000)))
me.console.log("ns/op: " + (elapsed * 1000000 / iterations))
}
runIndirectBenchmark() {
me.console.log("\n=== Indirect Access (Array[0]) ===")
local arr = new ArrayBox()
arr.push(0) // arr[0] = 0
local iterations = 100000000
local start = new TimeBox()
local startMs = start.now()
// 配列経由の間接アクセス(最適化が難しい)
loop(arr.get(0) < iterations) {
arr.set(0, arr.get(0) + 1)
}
local end = new TimeBox()
local elapsed = end.now() - startMs
me.console.log("Iterations: " + iterations)
me.console.log("Time: " + elapsed + "ms")
me.console.log("ops/sec: " + (iterations / (elapsed / 1000)))
me.console.log("ns/op: " + (elapsed * 1000000 / iterations))
// 速度比を計算して最適化の効果を示す
me.console.log("\n=== Analysis ===")
me.console.log("Direct access should be >10x faster than indirect")
}
}