luabench

package
v0.1.0-dev.121 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 3, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package luabench measures runtime and memory performance of transpiled Lua code. Benchmarks are TypeScript files in benchmarks/ that export a default function. The harness transpiles them, wraps with os.clock/collectgarbage measurement, and runs via LuaJIT (or another runtime).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LuaTargetForRuntime

func LuaTargetForRuntime(runtime string) transpiler.LuaTarget

LuaTargetForRuntime maps a runtime binary name to a transpiler LuaTarget.

func PrintLua

func PrintLua(results []Result)

PrintLua prints the transpiled Lua for each benchmark, grouped by name with tstl and optimized side by side.

func PrintTable

func PrintTable(results []Result)

PrintTable prints benchmark results as an aligned table with deltas. Results are expected in pairs: [tstl, optimized] for each benchmark.

Types

type Bench

type Bench struct {
	Name       string
	Iterations int // how many times the function is called for timing
}

Bench defines a benchmark to run.

type Result

type Result struct {
	Name       string
	EmitMode   transpiler.EmitMode
	TimeSec    float64
	Iterations int
	GarbageKB  float64
	TotalMemKB float64
	Lua        string // transpiled Lua source (main.ts only)
}

Result holds measurements from a single benchmark run.

func Run

func Run(b Bench, mode transpiler.EmitMode, runtime string) (Result, error)

Run transpiles a benchmark .ts file and measures its Lua performance.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL