HRTK includes a built-in benchmarking system for measuring the performance of your mod’s code paths inside the live server. Benchmarks use Hytale’sDocumentation Index
Fetch the complete documentation index at: https://docs.hrtk.frotty27.com/llms.txt
Use this file to discover all available pages before exploring further.
TimeRecorder for precise timing and support configurable warmup, iteration counts, and batch sizes.
@Benchmark
Annotate a method with@Benchmark to mark it as a performance benchmark. Benchmarks are executed via /hrtk bench and are not included in regular /hrtk run invocations.
Configuration Parameters
| Parameter | Default | Description |
|---|---|---|
warmup | 5 | Number of warmup iterations (not measured) |
iterations | 100 | Number of measured iterations |
batchSize | 1 | Operations per iteration (for throughput calculation) |
Complete Example Suite
BenchmarkContext
Injected into benchmark methods when you declare aBenchmarkContext parameter.
| Method | Description |
|---|---|
getIteration() | Current iteration number (0-based) |
getTotalIterations() | Total measured iterations |
isWarmup() | True during warmup phase |
startTimer() | Manually start timing |
stopTimer() | Manually stop timing |
Automatic vs. Manual Timing
By default, the entire method body is timed automatically. If you need to exclude setup or teardown code from measurement, use manual timing:- Automatic (default)
- Manual
If you call
startTimer() but forget to call stopTimer(), HRTK stops the timer automatically at the end of the iteration. The timing will still be accurate for the measured portion.Execution Phases
Warmup
The method runs
warmup times. These iterations are not measured. JIT compilation and caching happen during this phase.Measurement
The method runs
iterations times. Each execution is timed and recorded in a TimeRecorder.Output Format
Benchmark results appear in the console and are stored in the test results:Running Benchmarks
Next Steps
- API: Contexts - full BenchmarkContext method reference
- Running: Commands -
/hrtk benchcommand details - Codec Testing - benchmark serialization performance