move rhailib to herolib
This commit is contained in:
71
rhailib/benches/simple_rhai_bench/README.md
Normal file
71
rhailib/benches/simple_rhai_bench/README.md
Normal file
@@ -0,0 +1,71 @@
|
||||
# Minimal Rhailib Benchmark
|
||||
|
||||
A simplified, minimal benchmarking tool for rhailib performance testing.
|
||||
|
||||
## Overview
|
||||
|
||||
This benchmark focuses on simplicity and direct timing measurements:
|
||||
- Creates a single task (n=1) using Lua script
|
||||
- Measures latency using Redis timestamps
|
||||
- Uses existing worker binary
|
||||
- ~85 lines of code total
|
||||
|
||||
## Usage
|
||||
|
||||
### Prerequisites
|
||||
- Redis running on `127.0.0.1:6379`
|
||||
- Worker binary built: `cd src/worker && cargo build --release`
|
||||
|
||||
### Run Benchmark
|
||||
```bash
|
||||
# From project root
|
||||
cargo bench
|
||||
```
|
||||
|
||||
### Expected Output
|
||||
```
|
||||
🧹 Cleaning up Redis...
|
||||
🚀 Starting worker...
|
||||
📝 Creating single task...
|
||||
⏱️ Waiting for completion...
|
||||
✅ Task completed in 23.45ms
|
||||
🧹 Cleaning up...
|
||||
```
|
||||
|
||||
## Files
|
||||
|
||||
- `simple_bench.rs` - Main benchmark binary (85 lines)
|
||||
- `batch_task.lua` - Minimal Lua script for task creation (28 lines)
|
||||
- `Cargo.toml` - Dependencies and binary configuration
|
||||
- `README.md` - This file
|
||||
|
||||
## How It Works
|
||||
|
||||
1. **Cleanup**: Clear Redis queues and task details
|
||||
2. **Start Worker**: Spawn single worker process
|
||||
3. **Create Task**: Use Lua script to create one task with timestamp
|
||||
4. **Wait & Measure**: Poll task until complete, calculate latency
|
||||
5. **Cleanup**: Kill worker and clear Redis
|
||||
|
||||
## Latency Calculation
|
||||
|
||||
```
|
||||
latency_ms = updated_at - created_at
|
||||
```
|
||||
|
||||
Where:
|
||||
- `created_at`: Timestamp when task was created (Lua script)
|
||||
- `updated_at`: Timestamp when worker completed task
|
||||
|
||||
## Future Iterations
|
||||
|
||||
- **Iteration 2**: Small batches (n=5, n=10)
|
||||
- **Iteration 3**: Larger batches and script complexity
|
||||
- **Iteration 4**: Performance optimizations
|
||||
|
||||
## Benefits
|
||||
|
||||
- **Easy to Understand**: Single file, linear flow
|
||||
- **Direct Timing**: Redis timestamps, no complex stats
|
||||
- **Fast to Modify**: No abstractions or frameworks
|
||||
- **Reliable**: Simple Redis operations
|
Reference in New Issue
Block a user