summaryrefslogtreecommitdiff
path: root/cli/bench
diff options
context:
space:
mode:
Diffstat (limited to 'cli/bench')
-rw-r--r--cli/bench/main.rs16
-rw-r--r--cli/bench/metrics.rs108
2 files changed, 0 insertions, 124 deletions
diff --git a/cli/bench/main.rs b/cli/bench/main.rs
index fbaaf469e..e347d2e1c 100644
--- a/cli/bench/main.rs
+++ b/cli/bench/main.rs
@@ -15,7 +15,6 @@ use std::time::SystemTime;
mod http;
mod lsp;
-mod metrics;
fn read_json(filename: &str) -> Result<Value> {
let f = fs::File::open(filename)?;
@@ -452,37 +451,28 @@ async fn main() -> Result<()> {
..Default::default()
};
- let mut reporter = metrics::Reporter::new().await;
-
if benchmarks.contains(&"bundle") {
let bundle_size = bundle_benchmark(&deno_exe)?;
- reporter.write("bundle_size", &bundle_size);
new_data.bundle_size = bundle_size;
}
if benchmarks.contains(&"exec_time") {
let exec_times = run_exec_time(&deno_exe, &target_dir)?;
- for (name, data) in exec_times.iter() {
- reporter.write_one("exec_time", name, *data.get("mean").unwrap());
- }
new_data.benchmark = exec_times;
}
if benchmarks.contains(&"binary_size") {
let binary_sizes = get_binary_sizes(&target_dir)?;
- reporter.write("binary_size", &binary_sizes);
new_data.binary_size = binary_sizes;
}
if benchmarks.contains(&"cargo_deps") {
let cargo_deps = cargo_deps();
- reporter.write_one("cargo_deps", "cargo_deps", cargo_deps as i64);
new_data.cargo_deps = cargo_deps;
}
if benchmarks.contains(&"lsp") {
let lsp_exec_times = lsp::benchmarks(&deno_exe)?;
- reporter.write("lsp_exec_time", &lsp_exec_times);
new_data.lsp_exec_time = lsp_exec_times;
}
@@ -492,14 +482,12 @@ async fn main() -> Result<()> {
.iter()
.map(|(name, result)| (name.clone(), result.requests as i64))
.collect();
- reporter.write("req_per_sec", &req_per_sec);
new_data.req_per_sec = req_per_sec;
let max_latency = stats
.iter()
.map(|(name, result)| (name.clone(), result.latency))
.collect();
- reporter.write("max_latency", &max_latency);
new_data.max_latency = max_latency;
}
@@ -538,19 +526,15 @@ async fn main() -> Result<()> {
syscall_count.insert(name.to_string(), total as i64);
}
- reporter.write("thread_count", &thread_count);
new_data.thread_count = thread_count;
- reporter.write("syscall_count", &syscall_count);
new_data.syscall_count = syscall_count;
}
if benchmarks.contains(&"mem_usage") {
let max_memory = run_max_mem_benchmark(&deno_exe)?;
- reporter.write("max_memory", &max_memory);
new_data.max_memory = max_memory;
}
- reporter.submit().await;
if let Some(filename) = target_dir.join("bench.json").to_str() {
write_json(filename, &serde_json::to_value(&new_data)?)?;
} else {
diff --git a/cli/bench/metrics.rs b/cli/bench/metrics.rs
deleted file mode 100644
index 964fdde4b..000000000
--- a/cli/bench/metrics.rs
+++ /dev/null
@@ -1,108 +0,0 @@
-// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
-
-use google_storage1::api::Object;
-use google_storage1::hyper;
-use google_storage1::hyper_rustls;
-use google_storage1::oauth2;
-use google_storage1::Storage;
-use once_cell::sync::Lazy;
-use std::collections::HashMap;
-use std::io::Cursor;
-
-static GIT_HASH: Lazy<String> = Lazy::new(|| {
- test_util::run_collect(&["git", "rev-parse", "HEAD"], None, None, None, true)
- .0
- .trim()
- .to_string()
-});
-
-#[derive(serde::Serialize)]
-struct Metric<T: serde::Serialize> {
- name: String,
- value: T,
- sha1: String,
- #[serde(rename = "type")]
- type_: String,
- time: i64,
-}
-
-pub struct Reporter {
- wtr: csv::Writer<Vec<u8>>,
- gcloud_client: Option<Storage>,
-}
-
-impl Reporter {
- pub async fn new() -> Self {
- dotenv::dotenv().ok();
- let gcloud_client =
- match std::env::var("CI").map(|_| std::env::var("GOOGLE_SVC_KEY")) {
- Ok(Ok(key_str)) => {
- let secret = oauth2::parse_service_account_key(key_str)
- .expect("Failed to load service account key");
- let auth =
- oauth2::authenticator::ServiceAccountAuthenticator::builder(secret)
- .build()
- .await
- .unwrap();
- let client = hyper::Client::builder().build(
- hyper_rustls::HttpsConnectorBuilder::new()
- .with_native_roots()
- .https_or_http()
- .enable_http1()
- .enable_http2()
- .build(),
- );
- Some(Storage::new(client, auth))
- }
- _ => None,
- };
- Self {
- wtr: csv::Writer::from_writer(vec![]),
- gcloud_client,
- }
- }
-
- pub fn write_one<T: serde::Serialize>(
- &mut self,
- type_: &str,
- name: &str,
- value: T,
- ) {
- self
- .wtr
- .serialize(Metric {
- name: name.to_string(),
- type_: type_.to_string(),
- value,
- sha1: GIT_HASH.clone(),
- time: chrono::Utc::now().timestamp_millis(),
- })
- .unwrap();
- }
-
- pub fn write<T: serde::Serialize + Copy>(
- &mut self,
- type_: &str,
- hashmap: &HashMap<String, T>,
- ) {
- for (name, value) in hashmap {
- self.write_one(type_, name, *value);
- }
- }
-
- pub async fn submit(mut self) {
- self.wtr.flush().unwrap();
- if let Some(client) = self.gcloud_client.take() {
- let mut reader = Cursor::new(self.wtr.into_inner().unwrap());
- let object: Object = Object::default();
- client
- .objects()
- .insert(object, "deno_benchmark_data")
- .name(&format!("{}.csv", *GIT_HASH))
- .param("uploadType", "multipart")
- .upload(&mut reader, "text/csv".parse().unwrap())
- .await
- .unwrap();
- }
- }
-}