Update benchmark tests with filtering
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
;; Benchmark: 143ns
|
;; Benchmark: 130ns
|
||||||
;; Benchmark-Repeat: 14093
|
;; Benchmark-Repeat: 15355
|
||||||
;; Output: 5
|
;; Output: 5
|
||||||
(((fn [x] (fn [] x)) 5))
|
(((fn [x] (fn [] x)) 5))
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
;; Benchmark: 363ns
|
;; Benchmark: 336ns
|
||||||
;; Benchmark-Repeat: 5561
|
;; Benchmark-Repeat: 5959
|
||||||
;; examples/def_local_inlining.myc
|
;; examples/def_local_inlining.myc
|
||||||
;; Demonstrates potential for DefLocal-Inlining (Phase 2.5)
|
;; Demonstrates potential for DefLocal-Inlining (Phase 2.5)
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
;; Benchmark: 339ns
|
;; Benchmark: 237ns
|
||||||
;; Benchmark-Repeat: 6100
|
;; Benchmark-Repeat: 8555
|
||||||
;; Output: 5
|
;; Output: 5
|
||||||
(do
|
(do
|
||||||
(def y 1)
|
(def y 1)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
;; Benchmark: 217ns
|
;; Benchmark: 198ns
|
||||||
;; Benchmark-Repeat: 9500
|
;; Benchmark-Repeat: 10207
|
||||||
;; Nested Macro and Arithmetic example
|
;; Nested Macro and Arithmetic example
|
||||||
;; Output: 81
|
;; Output: 81
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
;; Benchmark: 503ns
|
;; Benchmark: 448ns
|
||||||
;; Benchmark-Repeat: 3987
|
;; Benchmark-Repeat: 4564
|
||||||
(do
|
(do
|
||||||
(def area (fn [x] (* PI x)))
|
(def area (fn [x] (* PI x)))
|
||||||
(area 10)
|
(area 10)
|
||||||
|
|||||||
@@ -274,13 +274,13 @@ impl Environment {
|
|||||||
|
|
||||||
// 2. Auto-apply: If the script returned a closure, we apply arguments to it.
|
// 2. Auto-apply: If the script returned a closure, we apply arguments to it.
|
||||||
let mut final_res = res;
|
let mut final_res = res;
|
||||||
if let Value::Object(obj) = &final_res {
|
if let Value::Object(obj) = &final_res
|
||||||
if let Some(closure) = obj.as_any().downcast_ref::<crate::ast::vm::Closure>() {
|
&& let Some(closure) = obj.as_any().downcast_ref::<crate::ast::vm::Closure>()
|
||||||
final_res = match vm.run_with_args(closure, args) {
|
{
|
||||||
Ok(v) => v,
|
final_res = match vm.run_with_args(closure, args) {
|
||||||
Err(e) => panic!("Myc Runtime Error (Closure): {}", e),
|
Ok(v) => v,
|
||||||
};
|
Err(e) => panic!("Myc Runtime Error (Closure): {}", e),
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. Resolve Tail Calls
|
// 3. Resolve Tail Calls
|
||||||
|
|||||||
+6
-1
@@ -49,7 +49,12 @@ fn main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
println!("🚀 Running benchmarks in RELEASE mode...\n");
|
println!("🚀 Running benchmarks in RELEASE mode...\n");
|
||||||
let results = tester::run_benchmarks(cli.update_bench);
|
let filter = cli
|
||||||
|
.file
|
||||||
|
.as_ref()
|
||||||
|
.and_then(|p| p.file_name())
|
||||||
|
.map(|n| n.to_string_lossy().to_string());
|
||||||
|
let results = tester::run_benchmarks(cli.update_bench, filter.as_deref());
|
||||||
for res in results {
|
for res in results {
|
||||||
let diff = res
|
let diff = res
|
||||||
.diff_pct
|
.diff_pct
|
||||||
|
|||||||
+37
-14
@@ -252,21 +252,34 @@ impl CompilerApp {
|
|||||||
self.output_log = log;
|
self.output_log = log;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_benchmarks(&mut self, update: bool) {
|
fn run_benchmarks(&mut self, update: bool, only_current: bool) {
|
||||||
use myc::utils::tester;
|
use myc::utils::tester;
|
||||||
|
|
||||||
|
let filter = if only_current {
|
||||||
|
self.current_example_path
|
||||||
|
.as_ref()
|
||||||
|
.and_then(|p| p.file_name())
|
||||||
|
.map(|n| n.to_string_lossy().to_string())
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
|
||||||
if cfg!(debug_assertions) && !update {
|
if cfg!(debug_assertions) && !update {
|
||||||
self.output_log = String::from(
|
self.output_log = String::from(
|
||||||
"⚠️ WARNING: Benchmarks in Debug mode are inaccurate!\nUse Release build for real measurements.\n\n",
|
"⚠️ WARNING: Benchmarks in Debug mode are inaccurate!\nUse Release build for real measurements.\n\n",
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
self.output_log = String::from(if update {
|
self.output_log = format!(
|
||||||
"UPDATING BASELINES...\n\n"
|
"{}...\n\n",
|
||||||
} else {
|
match (update, only_current) {
|
||||||
"RUNNING BENCHMARKS...\n\n"
|
(true, true) => "UPDATING BASELINE FOR CURRENT SCRIPT",
|
||||||
});
|
(true, false) => "UPDATING ALL BASELINES",
|
||||||
|
(false, _) => "RUNNING BENCHMARKS",
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let results = tester::run_benchmarks(update);
|
let results = tester::run_benchmarks(update, filter.as_deref());
|
||||||
let mut log = self.output_log.clone();
|
let mut log = self.output_log.clone();
|
||||||
|
|
||||||
for res in results {
|
for res in results {
|
||||||
@@ -331,21 +344,31 @@ impl eframe::App for CompilerApp {
|
|||||||
|
|
||||||
let is_debug = cfg!(debug_assertions);
|
let is_debug = cfg!(debug_assertions);
|
||||||
ui.add_enabled_ui(!is_debug, |ui: &mut egui::Ui| {
|
ui.add_enabled_ui(!is_debug, |ui: &mut egui::Ui| {
|
||||||
let btn = ui.button("Run Benchmarks");
|
let btn = ui.button("Run All Benchmarks");
|
||||||
if is_debug {
|
if is_debug {
|
||||||
btn.on_hover_text("Benchmarks are only available in Release builds.");
|
btn.on_hover_text("Benchmarks are only available in Release builds.");
|
||||||
} else if btn.clicked() {
|
} else if btn.clicked() {
|
||||||
self.run_benchmarks(false);
|
self.run_benchmarks(false, false);
|
||||||
ui.close();
|
ui.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
let btn_base = ui.button("Update Baselines");
|
let btn_base_all = ui.button("Update All Baselines");
|
||||||
if is_debug {
|
if is_debug {
|
||||||
btn_base.on_hover_text(
|
btn_base_all.on_hover_text(
|
||||||
"Updating baselines is only allowed in Release builds.",
|
"Updating baselines is only allowed in Release builds.",
|
||||||
);
|
);
|
||||||
} else if btn_base.clicked() {
|
} else if btn_base_all.clicked() {
|
||||||
self.run_benchmarks(true);
|
self.run_benchmarks(true, false);
|
||||||
|
ui.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
let btn_base_curr = ui.button("Update Current Baseline");
|
||||||
|
if is_debug {
|
||||||
|
btn_base_curr.on_hover_text(
|
||||||
|
"Updating baselines is only allowed in Release builds.",
|
||||||
|
);
|
||||||
|
} else if btn_base_curr.clicked() {
|
||||||
|
self.run_benchmarks(true, true);
|
||||||
ui.close();
|
ui.close();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -406,7 +429,7 @@ impl eframe::App for CompilerApp {
|
|||||||
if is_debug {
|
if is_debug {
|
||||||
bench_btn.on_hover_text("Benchmarks are only available in Release builds.");
|
bench_btn.on_hover_text("Benchmarks are only available in Release builds.");
|
||||||
} else if bench_btn.clicked() {
|
} else if bench_btn.clicked() {
|
||||||
self.run_benchmarks(false);
|
self.run_benchmarks(false, false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
+9
-3
@@ -77,7 +77,7 @@ pub fn run_functional_tests_with_optimization(enabled: bool) -> Vec<TestResult>
|
|||||||
results
|
results
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn run_benchmarks(update: bool) -> Vec<BenchmarkResult> {
|
pub fn run_benchmarks(update: bool, filter: Option<&str>) -> Vec<BenchmarkResult> {
|
||||||
let mut results = Vec::new();
|
let mut results = Vec::new();
|
||||||
let entries = fs::read_dir("examples").unwrap();
|
let entries = fs::read_dir("examples").unwrap();
|
||||||
let is_release = !cfg!(debug_assertions);
|
let is_release = !cfg!(debug_assertions);
|
||||||
@@ -90,8 +90,14 @@ pub fn run_benchmarks(update: bool) -> Vec<BenchmarkResult> {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let content = fs::read_to_string(&path).unwrap();
|
|
||||||
let name = path.file_name().unwrap().to_string_lossy().to_string();
|
let name = path.file_name().unwrap().to_string_lossy().to_string();
|
||||||
|
if let Some(f) = filter
|
||||||
|
&& name != f
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
let content = fs::read_to_string(&path).unwrap();
|
||||||
|
|
||||||
let baseline_match = baseline_re.captures(&content);
|
let baseline_match = baseline_re.captures(&content);
|
||||||
let repeat_match = repeat_re.captures(&content);
|
let repeat_match = repeat_re.captures(&content);
|
||||||
@@ -311,7 +317,7 @@ mod tests {
|
|||||||
#[cfg(not(debug_assertions))]
|
#[cfg(not(debug_assertions))]
|
||||||
fn benchmark_regression_test() {
|
fn benchmark_regression_test() {
|
||||||
use super::*;
|
use super::*;
|
||||||
let results = run_benchmarks(false);
|
let results = run_benchmarks(false, None);
|
||||||
let failures: Vec<_> = results.iter().filter(|r| r.status == "FAILED").collect();
|
let failures: Vec<_> = results.iter().filter(|r| r.status == "FAILED").collect();
|
||||||
|
|
||||||
if !failures.is_empty() {
|
if !failures.is_empty() {
|
||||||
|
|||||||
Reference in New Issue
Block a user