From ab5ecabe222df3f16748629b244b5e8265760d91 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Sun, 10 Jan 2021 08:13:38 -0500 Subject: Add cargo_deps to benchmarks (#9075) --- cli/bench/main.rs | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'cli/bench') diff --git a/cli/bench/main.rs b/cli/bench/main.rs index d796237d1..012810c1f 100644 --- a/cli/bench/main.rs +++ b/cli/bench/main.rs @@ -405,6 +405,21 @@ fn run_max_mem_benchmark(deno_exe: &PathBuf) -> Result { Ok(Value::Object(results)) } +fn cargo_deps() -> usize { + let cargo_lock = test_util::root_path().join("Cargo.lock"); + let mut count = 0; + let file = std::fs::File::open(cargo_lock).unwrap(); + use std::io::BufRead; + for line in std::io::BufReader::new(file).lines() { + if line.unwrap().starts_with("[[package]]") { + count += 1 + } + } + println!("cargo_deps {}", count); + assert!(count > 10); // Sanity check. + count +} + /* TODO(SyrupThinker) Switch to the #[bench] attribute once @@ -425,10 +440,6 @@ fn main() -> Result<()> { env::set_current_dir(&test_util::root_path())?; let mut new_data: Map = Map::new(); - - new_data.insert("binary_size".to_string(), get_binary_sizes(&target_dir)?); - new_data.insert("bundle_size".to_string(), bundle_benchmark(&deno_exe)?); - new_data.insert( "created_at".to_string(), Value::String( @@ -451,6 +462,10 @@ fn main() -> Result<()> { ), ); + new_data.insert("binary_size".to_string(), get_binary_sizes(&target_dir)?); + new_data.insert("bundle_size".to_string(), bundle_benchmark(&deno_exe)?); + new_data.insert("cargo_deps".to_string(), Value::Number(cargo_deps().into())); + // TODO(ry) The "benchmark" benchmark should actually be called "exec_time". // When this is changed, the historical data in gh-pages branch needs to be // changed too. -- cgit v1.2.3