summaryrefslogtreecommitdiff
path: root/cli/bench
diff options
context:
space:
mode:
Diffstat (limited to 'cli/bench')
-rw-r--r--cli/bench/http.rs6
-rw-r--r--cli/bench/lsp.rs10
-rw-r--r--cli/bench/main.rs17
-rw-r--r--cli/bench/throughput.rs6
4 files changed, 19 insertions, 20 deletions
diff --git a/cli/bench/http.rs b/cli/bench/http.rs
index af7eef942..f954223a0 100644
--- a/cli/bench/http.rs
+++ b/cli/bench/http.rs
@@ -1,9 +1,7 @@
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
use super::Result;
-use std::{
- collections::HashMap, path::PathBuf, process::Command, time::Duration,
-};
+use std::{collections::HashMap, path::Path, process::Command, time::Duration};
pub use test_util::{parse_wrk_output, WrkOutput as HttpBenchmarkResult};
// Some of the benchmarks in this file have been renamed. In case the history
@@ -15,7 +13,7 @@ pub use test_util::{parse_wrk_output, WrkOutput as HttpBenchmarkResult};
const DURATION: &str = "20s";
pub(crate) fn benchmark(
- target_path: &PathBuf,
+ target_path: &Path,
) -> Result<HashMap<String, HttpBenchmarkResult>> {
let deno_exe = test_util::deno_exe_path();
let deno_exe = deno_exe.to_str().unwrap();
diff --git a/cli/bench/lsp.rs b/cli/bench/lsp.rs
index 63e1821d4..da02db486 100644
--- a/cli/bench/lsp.rs
+++ b/cli/bench/lsp.rs
@@ -14,7 +14,7 @@ use std::collections::HashMap;
use std::io::BufRead;
use std::io::Read;
use std::io::Write;
-use std::path::PathBuf;
+use std::path::Path;
use std::process::ChildStdin;
use std::process::ChildStdout;
use std::process::Command;
@@ -135,7 +135,7 @@ impl Drop for LspClient {
}
impl LspClient {
- fn new(deno_exe: &PathBuf) -> Result<Self, AnyError> {
+ fn new(deno_exe: &Path) -> Result<Self, AnyError> {
let mut child = Command::new(deno_exe)
.arg("lsp")
.stdin(Stdio::piped())
@@ -244,7 +244,7 @@ impl LspClient {
/// A benchmark that opens a 8000+ line TypeScript document, adds a function to
/// the end of the document and does a level of hovering and gets quick fix
/// code actions.
-fn bench_big_file_edits(deno_exe: &PathBuf) -> Result<Duration, AnyError> {
+fn bench_big_file_edits(deno_exe: &Path) -> Result<Duration, AnyError> {
let mut client = LspClient::new(deno_exe)?;
let params: Value = serde_json::from_slice(FIXTURE_INIT_JSON)?;
@@ -302,7 +302,7 @@ fn bench_big_file_edits(deno_exe: &PathBuf) -> Result<Duration, AnyError> {
}
/// A test that starts up the LSP, opens a single line document, and exits.
-fn bench_startup_shutdown(deno_exe: &PathBuf) -> Result<Duration, AnyError> {
+fn bench_startup_shutdown(deno_exe: &Path) -> Result<Duration, AnyError> {
let mut client = LspClient::new(deno_exe)?;
let params: Value = serde_json::from_slice(FIXTURE_INIT_JSON)?;
@@ -338,7 +338,7 @@ fn bench_startup_shutdown(deno_exe: &PathBuf) -> Result<Duration, AnyError> {
/// Generate benchmarks for the LSP server.
pub(crate) fn benchmarks(
- deno_exe: &PathBuf,
+ deno_exe: &Path,
) -> Result<HashMap<String, u64>, AnyError> {
println!("-> Start benchmarking lsp");
let mut exec_times = HashMap::new();
diff --git a/cli/bench/main.rs b/cli/bench/main.rs
index 8a91b86d6..8890ec79c 100644
--- a/cli/bench/main.rs
+++ b/cli/bench/main.rs
@@ -8,6 +8,7 @@ use std::collections::HashMap;
use std::convert::From;
use std::env;
use std::fs;
+use std::path::Path;
use std::path::PathBuf;
use std::process::Command;
use std::process::Stdio;
@@ -126,8 +127,8 @@ const EXEC_TIME_BENCHMARKS: &[(&str, &[&str], Option<i32>)] = &[
const RESULT_KEYS: &[&str] =
&["mean", "stddev", "user", "system", "min", "max"];
fn run_exec_time(
- deno_exe: &PathBuf,
- target_dir: &PathBuf,
+ deno_exe: &Path,
+ target_dir: &Path,
) -> Result<HashMap<String, HashMap<String, f64>>> {
let hyperfine_exe = test_util::prebuilt_tool_path("hyperfine");
@@ -218,7 +219,7 @@ fn rlib_size(target_dir: &std::path::Path, prefix: &str) -> u64 {
const BINARY_TARGET_FILES: &[&str] =
&["CLI_SNAPSHOT.bin", "COMPILER_SNAPSHOT.bin"];
-fn get_binary_sizes(target_dir: &PathBuf) -> Result<HashMap<String, u64>> {
+fn get_binary_sizes(target_dir: &Path) -> Result<HashMap<String, u64>> {
let mut sizes = HashMap::<String, u64>::new();
let mut mtimes = HashMap::<String, SystemTime>::new();
@@ -276,7 +277,7 @@ const BUNDLES: &[(&str, &str)] = &[
("file_server", "./test_util/std/http/file_server.ts"),
("gist", "./test_util/std/examples/gist.ts"),
];
-fn bundle_benchmark(deno_exe: &PathBuf) -> Result<HashMap<String, u64>> {
+fn bundle_benchmark(deno_exe: &Path) -> Result<HashMap<String, u64>> {
let mut sizes = HashMap::<String, u64>::new();
for (name, url) in BUNDLES {
@@ -304,7 +305,7 @@ fn bundle_benchmark(deno_exe: &PathBuf) -> Result<HashMap<String, u64>> {
Ok(sizes)
}
-fn run_throughput(deno_exe: &PathBuf) -> Result<HashMap<String, f64>> {
+fn run_throughput(deno_exe: &Path) -> Result<HashMap<String, f64>> {
let mut m = HashMap::<String, f64>::new();
m.insert("100M_tcp".to_string(), throughput::tcp(deno_exe, 100)?);
@@ -315,7 +316,7 @@ fn run_throughput(deno_exe: &PathBuf) -> Result<HashMap<String, f64>> {
Ok(m)
}
-fn run_http(target_dir: &PathBuf, new_data: &mut BenchResult) -> Result<()> {
+fn run_http(target_dir: &Path, new_data: &mut BenchResult) -> Result<()> {
let stats = http::benchmark(target_dir)?;
new_data.req_per_sec = stats
@@ -332,7 +333,7 @@ fn run_http(target_dir: &PathBuf, new_data: &mut BenchResult) -> Result<()> {
}
fn run_strace_benchmarks(
- deno_exe: &PathBuf,
+ deno_exe: &Path,
new_data: &mut BenchResult,
) -> Result<()> {
use std::io::Read;
@@ -372,7 +373,7 @@ fn run_strace_benchmarks(
Ok(())
}
-fn run_max_mem_benchmark(deno_exe: &PathBuf) -> Result<HashMap<String, u64>> {
+fn run_max_mem_benchmark(deno_exe: &Path) -> Result<HashMap<String, u64>> {
let mut results = HashMap::<String, u64>::new();
for (name, args, return_code) in EXEC_TIME_BENCHMARKS {
diff --git a/cli/bench/throughput.rs b/cli/bench/throughput.rs
index 83032e7a1..de18089bb 100644
--- a/cli/bench/throughput.rs
+++ b/cli/bench/throughput.rs
@@ -2,7 +2,7 @@
use super::Result;
use std::{
- path::PathBuf,
+ path::Path,
process::Command,
time::{Duration, Instant},
};
@@ -11,7 +11,7 @@ const MB: usize = 1024 * 1024;
const SERVER_ADDR: &str = "0.0.0.0:4544";
const CLIENT_ADDR: &str = "127.0.0.1 4544";
-pub(crate) fn cat(deno_exe: &PathBuf, megs: usize) -> f64 {
+pub(crate) fn cat(deno_exe: &Path, megs: usize) -> f64 {
let size = megs * MB;
let shell_cmd = format!(
"{} run --allow-read cli/tests/cat.ts /dev/zero | head -c {}",
@@ -28,7 +28,7 @@ pub(crate) fn cat(deno_exe: &PathBuf, megs: usize) -> f64 {
(end - start).as_secs_f64()
}
-pub(crate) fn tcp(deno_exe: &PathBuf, megs: usize) -> Result<f64> {
+pub(crate) fn tcp(deno_exe: &Path, megs: usize) -> Result<f64> {
let size = megs * MB;
// The GNU flavor of `nc` requires the `-N` flag to shutdown the network socket after EOF on stdin