Fixtures
Shared test data — hex, @file, data/encoding, format/selector
Fixtures define shared test data passed to every language implementation. They ensure all languages operate on identical input, so your benchmarks compare apples to apples.
Each language receives fixture data in its native type. The table below shows the mapping:
| Language | Fixture type |
|---|---|
| Go | []byte |
| TypeScript | Uint8Array |
| Rust | &[u8] |
| Python | bytes |
| C | uint8_t* + length |
| C# | byte[] |
| Zig | []const u8 |
You can provide binary data as a hex-encoded string directly in the fixture. This works well for small, fixed test vectors.
@file for larger payloads.1fixture shortData {2 hex: "68656c6c6f20776f726c64" # "hello world" in UTF-83}4
5fixture address {6 hex: "d8da6bf26964af9d7eed9e03e53415d37aa96045" # 20-byte Ethereum address7}8
9bench hashShort {10 go: keccak256(shortData)11 ts: keccak256(shortData)12 rust: keccak256(&shortData)13}For larger payloads, load hex from an external file using the @file directive. The path is relative to the .bench file.
1fixture largePayload {2 hex: @file("fixtures/sort/sort_1000.hex")3}4
5fixture abiData {6 hex: @file("fixtures/abi/erc20_calldata.hex")7}8
9bench sortLarge {10 go: bubbleSort(largePayload)11 ts: bubbleSort(largePayload)12 rust: bubble_sort(&largePayload)13}fixtures/ subdirectory. Organize by benchmark type (e.g. fixtures/sort/, fixtures/keccak/).When your data is not hex-encoded, use the data field with an encoding. The encoding controls how the bytes are decoded.
| encoding | Use |
|---|---|
raw | Raw binary bytes |
utf8 | UTF-8 string |
base64 | Base64-encoded string |
encoding: raw for binary, utf8 for strings, base64 for base64-encoded data.1fixture packetRaw {2 data: @file("fixtures/net/packet.bin")3 encoding: raw4}5
6fixture payloadUtf8 {7 data: "hello world"8 encoding: utf89}10
11fixture payloadB64 {12 data: "aGVsbG8gd29ybGQ="13 encoding: base6414}When your data is in JSON or CSV, use format and selector to extract a specific value. The selector syntax depends on the format.
$.path); CSV uses row,col (0-indexed).1fixture requestId {2 data: @file("fixtures/requests.json")3 format: json4 selector: "$.items[0].id"5}6
7fixture csvCell {8 data: @file("fixtures/table.csv")9 format: csv10 selector: "1,2" # row,col (0-indexed)11}Fixtures support optional metadata fields:
| Field | Purpose |
|---|---|
description | Human-readable description |
shape | JSON-like descriptor for metadata (e.g. { rows: 64, cols: 64 }) |
1fixture keccakInput {2 description: "32-byte input for keccak256 hashing"3 hex: "68656c6c6f20776f726c6468656c6c6f20776f726c6468656c6c6f20776f72"4}5
6fixture matrixData {7 hex: @file("fixtures/matmul/mat_64.hex")8 shape: { rows: 64, cols: 64, dtype: "float64" }9}The table below summarizes the fixture types and their syntax:
| Fixture type | Syntax |
|---|---|
| Inline hex | hex: "68656c6c6f" |
| File hex | hex: @file("path/to/file.hex") |
| Raw / UTF-8 / Base64 | data: ... + encoding: raw | utf8 | base64 |
| JSON extraction | data: @file(...), format: json, selector: "$.path" |
| CSV extraction | data: @file(...), format: csv, selector: "row,col" |
See the Fixtures Guide for practical patterns and scaling strategies.