summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2024-05-01 22:22:37 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2024-05-01 22:22:37 +0200
commit23986f7e7278b20833c40b6c257bd59ecc01bf85 (patch)
tree302117734faef64a6c4fdad70c14128ad5110db8
parent537be83c9faa105a73465fd18227de1e54859403 (diff)
downloadrebel-23986f7e7278b20833c40b6c257bd59ecc01bf85.tar
rebel-23986f7e7278b20833c40b6c257bd59ecc01bf85.zip
rebel-lang: add execute benchmark
-rw-r--r--crates/rebel-lang/benches/recipe.rs27
1 files changed, 25 insertions, 2 deletions
diff --git a/crates/rebel-lang/benches/recipe.rs b/crates/rebel-lang/benches/recipe.rs
index 6ee1697..5b9a440 100644
--- a/crates/rebel-lang/benches/recipe.rs
+++ b/crates/rebel-lang/benches/recipe.rs
@@ -24,7 +24,7 @@ fn context() -> Context {
ModuleEntry::Def(Var {
explicit_type: Type::Str,
inferred_type: Type::Str,
- value: Value::Uninitialized,
+ value: Value::Str("workdir".to_owned()),
initialized: true,
}),
);
@@ -33,7 +33,7 @@ fn context() -> Context {
ModuleEntry::Def(Var {
explicit_type: Type::Str,
inferred_type: Type::Str,
- value: Value::Uninitialized,
+ value: Value::Str("gpm".to_owned()),
initialized: true,
}),
);
@@ -74,3 +74,26 @@ fn typecheck(bencher: divan::Bencher) {
}
});
}
+
+#[divan::bench]
+fn execute(bencher: divan::Bencher) {
+ let recipe = recipe();
+ let ctx = context();
+
+ for stmt in &recipe {
+ stmt.validate().unwrap();
+ }
+
+ bencher.bench(|| {
+ let mut ctx = divan::black_box(ctx.clone());
+
+ for stmt in divan::black_box(&recipe) {
+ let ast::RecipeStmt::BlockStmt(stmt) = stmt else {
+ // TODO: Execute other statements
+ continue;
+ };
+
+ ctx.execute(stmt).unwrap();
+ }
+ });
+}