| Crates.io | anchor-yard |
| lib.rs | anchor-yard |
| version | 0.2.0 |
| created_at | 2025-08-07 05:34:11.212938+00 |
| updated_at | 2025-08-07 11:41:52.580427+00 |
| description | A simple and effective performance profiling and world snapshot tool for the shipyard ECS framework. |
| homepage | |
| repository | https://github.com/Npixel-Eclipse/anchor-yard |
| max_upload_size | |
| id | 1784716 |
| size | 19,987 |
⚓ anchor-yard is a simple and effective performance profiling and world snapshot tool for the shipyard ECS.
It helps you identify slow systems and capture the world state at the time of execution, making it easy to debug and analyze bottlenecks.
When developing complex games or simulations with shipyard, it can be difficult to figure out why a particular system is slowing down. anchor-yard solves this problem by:
World state when a system's execution time exceeds a set threshold.#[snapshot_system] attribute.#[snapshot_system] attribute to your system functions.World to a file and restore it perfectly later.Add anchor-yard to your Cargo.toml file.
[dependencies]
anchor-yard = "0.1.0" # Use your desired version
shipyard = "0.6"
serde = { version = "1.0", features = ["derive"] }
Add the #[snapshot_system] attribute to the system you want to profile. You can set threshold_ms to specify the execution time that triggers a snapshot.
use anchor_yard::snapshot_system;
use shipyard::{View, ViewMut};
#[snapshot_system(threshold_ms = 10)] // Creates a snapshot if it takes longer than 10ms
fn slow_combat_system(mut healths: ViewMut<Health>, positions: View<Position>) {
// ... system logic ...
std::thread::sleep(std::time::Duration::from_millis(15));
}
fn fast_movement_system(mut positions: ViewMut<Position>, velocities: View<Velocity>) {
// ... system logic
}
When running your system, use run_default_workload_with_snapshot.
use anchor_yard::WorldSnapshotExt;
let mut world = World::new();
// ... add entities and components ...
// Add workload
let workload = (slow_combat_system, fast_movement_system).into_workload();
world.add_workload(workload);
// Run workload
world.run_default_workload_with_snapshot().unwrap();
Now, if slow_combat_system takes longer than 10ms to execute, a slow_combat_system_TIMESTAMP.snapshot file will be created in the snapshots/ directory!
anchor-yard follows a modular design:
anchor-yard: The main crate that integrates all features for the easiest use.anchor-yard-core: Contains the core logic for creating, saving, and restoring snapshots.anchor-yard-macros: Provides the #[snapshot_system] procedural macro.