diff options
Diffstat (limited to 'cli/bench/main.rs')
-rw-r--r-- | cli/bench/main.rs | 91 |
1 files changed, 39 insertions, 52 deletions
diff --git a/cli/bench/main.rs b/cli/bench/main.rs index c6f786e31..8a91b86d6 100644 --- a/cli/bench/main.rs +++ b/cli/bench/main.rs @@ -1,18 +1,20 @@ // Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. use deno_core::error::AnyError; -use deno_core::serde_json::{self, Value}; +use deno_core::serde_json; +use deno_core::serde_json::Value; use serde::Serialize; +use std::collections::HashMap; +use std::convert::From; +use std::env; +use std::fs; +use std::path::PathBuf; +use std::process::Command; +use std::process::Stdio; use std::time::SystemTime; -use std::{ - collections::HashMap, - convert::From, - env, fs, - path::PathBuf, - process::{Command, Stdio}, -}; mod http; +mod lsp; mod throughput; fn read_json(filename: &str) -> Result<Value> { @@ -408,42 +410,25 @@ fn cargo_deps() -> usize { count } -#[derive(Serialize)] +#[derive(Default, Serialize)] struct BenchResult { created_at: String, sha1: String, - binary_size: HashMap<String, u64>, - bundle_size: HashMap<String, u64>, - cargo_deps: usize, + // 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. benchmark: HashMap<String, HashMap<String, f64>>, - throughput: HashMap<String, f64>, + binary_size: HashMap<String, u64>, + bundle_size: HashMap<String, u64>, + cargo_deps: usize, + max_latency: HashMap<String, f64>, max_memory: HashMap<String, u64>, + lsp_exec_time: HashMap<String, u64>, req_per_sec: HashMap<String, u64>, - max_latency: HashMap<String, f64>, - thread_count: HashMap<String, u64>, syscall_count: HashMap<String, u64>, -} - -impl BenchResult { - pub fn new() -> BenchResult { - BenchResult { - created_at: String::new(), - sha1: String::new(), - binary_size: HashMap::new(), - bundle_size: HashMap::new(), - cargo_deps: 0, - benchmark: HashMap::new(), - throughput: HashMap::new(), - max_memory: HashMap::new(), - req_per_sec: HashMap::new(), - max_latency: HashMap::new(), - thread_count: HashMap::new(), - syscall_count: HashMap::new(), - } - } + thread_count: HashMap<String, u64>, + throughput: HashMap<String, f64>, } /* @@ -465,24 +450,26 @@ fn main() -> Result<()> { env::set_current_dir(&test_util::root_path())?; - let mut new_data = BenchResult::new(); - new_data.created_at = - chrono::Utc::now().to_rfc3339_opts(chrono::SecondsFormat::Secs, true); - new_data.sha1 = test_util::run_collect( - &["git", "rev-parse", "HEAD"], - None, - None, - None, - true, - ) - .0 - .trim() - .to_string(); - - new_data.binary_size = get_binary_sizes(&target_dir)?; - new_data.bundle_size = bundle_benchmark(&deno_exe)?; - new_data.cargo_deps = cargo_deps(); - new_data.benchmark = run_exec_time(&deno_exe, &target_dir)?; + let mut new_data = BenchResult { + created_at: chrono::Utc::now() + .to_rfc3339_opts(chrono::SecondsFormat::Secs, true), + sha1: test_util::run_collect( + &["git", "rev-parse", "HEAD"], + None, + None, + None, + true, + ) + .0 + .trim() + .to_string(), + benchmark: run_exec_time(&deno_exe, &target_dir)?, + binary_size: get_binary_sizes(&target_dir)?, + bundle_size: bundle_benchmark(&deno_exe)?, + cargo_deps: cargo_deps(), + lsp_exec_time: lsp::benchmarks(&deno_exe)?, + ..Default::default() + }; // Cannot run throughput benchmark on windows because they don't have nc or // pipe. |