rename worker to actor
This commit is contained in:
@@ -23,23 +23,23 @@ fn cleanup_redis() -> Result<(), redis::RedisError> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn start_worker() -> Result<Child, std::io::Error> {
|
||||
fn start_actor() -> Result<Child, std::io::Error> {
|
||||
Command::new("cargo")
|
||||
.args(&[
|
||||
"run",
|
||||
"--release",
|
||||
"--bin",
|
||||
"worker",
|
||||
"actor",
|
||||
"--",
|
||||
"--circle",
|
||||
CIRCLE_NAME,
|
||||
"--redis-url",
|
||||
REDIS_URL,
|
||||
"--worker-id",
|
||||
"bench_worker",
|
||||
"--actor-id",
|
||||
"bench_actor",
|
||||
"--preserve-tasks",
|
||||
])
|
||||
.current_dir("src/worker")
|
||||
.current_dir("src/actor")
|
||||
.stdout(Stdio::null())
|
||||
.stderr(Stdio::null())
|
||||
.spawn()
|
||||
@@ -126,26 +126,26 @@ fn wait_for_batch_completion(task_keys: &[String]) -> Result<f64, Box<dyn std::e
|
||||
}
|
||||
}
|
||||
|
||||
fn cleanup_worker(mut worker: Child) -> Result<(), std::io::Error> {
|
||||
worker.kill()?;
|
||||
worker.wait()?;
|
||||
fn cleanup_actor(mut actor: Child) -> Result<(), std::io::Error> {
|
||||
actor.kill()?;
|
||||
actor.wait()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn bench_single_rhai_task(c: &mut Criterion) {
|
||||
// Setup: ensure worker is built
|
||||
// Setup: ensure actor is built
|
||||
let _ = Command::new("cargo")
|
||||
.args(&["build", "--release", "--bin", "worker"])
|
||||
.current_dir("src/worker")
|
||||
.args(&["build", "--release", "--bin", "actor"])
|
||||
.current_dir("src/actor")
|
||||
.output()
|
||||
.expect("Failed to build worker");
|
||||
.expect("Failed to build actor");
|
||||
|
||||
// Clean up before starting
|
||||
cleanup_redis().expect("Failed to cleanup Redis");
|
||||
|
||||
// Start worker once and reuse it
|
||||
let worker = start_worker().expect("Failed to start worker");
|
||||
thread::sleep(Duration::from_millis(1000)); // Give worker time to start
|
||||
// Start actor once and reuse it
|
||||
let actor = start_actor().expect("Failed to start actor");
|
||||
thread::sleep(Duration::from_millis(1000)); // Give actor time to start
|
||||
|
||||
let mut group = c.benchmark_group("rhai_task_execution");
|
||||
group.sample_size(10); // Reduce sample size
|
||||
@@ -174,8 +174,8 @@ fn bench_single_rhai_task(c: &mut Criterion) {
|
||||
|
||||
group.finish();
|
||||
|
||||
// Cleanup worker
|
||||
cleanup_worker(worker).expect("Failed to cleanup worker");
|
||||
// Cleanup actor
|
||||
cleanup_actor(actor).expect("Failed to cleanup actor");
|
||||
cleanup_redis().expect("Failed to cleanup Redis");
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user