mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-04-01 10:01:07 +02:00
feat(bench): add tauri_3mb_transfer test (#1895)
This commit is contained in:
@@ -39,7 +39,9 @@ fn main() {
|
||||
|
||||
// write json's
|
||||
utils::write_json(
|
||||
tauri_data.to_str().expect("Something wrong with tauri_data"),
|
||||
tauri_data
|
||||
.to_str()
|
||||
.expect("Something wrong with tauri_data"),
|
||||
&serde_json::to_value(&all_data).expect("Unable to build final json (alls)"),
|
||||
)
|
||||
.expect(format!("Unable to write {:?}", tauri_data).as_str());
|
||||
|
||||
@@ -29,16 +29,13 @@ fn get_all_benchmarks() -> Vec<(String, String)> {
|
||||
utils::get_target()
|
||||
),
|
||||
),
|
||||
/*
|
||||
FIXME: require next release of tao
|
||||
(
|
||||
"tauri_3mb_transfer".into(),
|
||||
format!(
|
||||
"tests/target/{}/release/tauri_3mb_transfer",
|
||||
"tests/target/{}/release/bench_files_transfer",
|
||||
utils::get_target()
|
||||
),
|
||||
),
|
||||
*/
|
||||
]
|
||||
}
|
||||
|
||||
@@ -250,6 +247,16 @@ fn run_exec_time(target_dir: &Path) -> Result<HashMap<String, HashMap<String, f6
|
||||
}
|
||||
|
||||
fn main() -> Result<()> {
|
||||
// download big files if not present
|
||||
let json_3mb = utils::home_path().join(".tauri_3mb.json");
|
||||
|
||||
if !json_3mb.exists() {
|
||||
utils::download_file(
|
||||
"https://github.com/lemarier/tauri-test/releases/download/v2.0.0/json_3mb.json",
|
||||
json_3mb,
|
||||
);
|
||||
}
|
||||
|
||||
println!("Starting tauri benchmark");
|
||||
|
||||
let target_dir = utils::target_dir();
|
||||
|
||||
@@ -5,7 +5,13 @@
|
||||
use anyhow::Result;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::Value;
|
||||
use std::{collections::HashMap, fs, io::{BufRead, BufReader}, path::PathBuf, process::{Command, Output, Stdio}};
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
fs,
|
||||
io::{BufRead, BufReader},
|
||||
path::PathBuf,
|
||||
process::{Command, Output, Stdio},
|
||||
};
|
||||
|
||||
#[derive(Default, Clone, Serialize, Deserialize, Debug)]
|
||||
pub struct BenchResult {
|
||||
@@ -51,6 +57,14 @@ pub fn bench_root_path() -> PathBuf {
|
||||
PathBuf::from(env!("CARGO_MANIFEST_DIR"))
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn home_path() -> PathBuf {
|
||||
#[cfg(any(target_os = "macos", target_os = "linux"))]
|
||||
return PathBuf::from(env!("HOME"));
|
||||
#[cfg(any(target_os = "windows"))]
|
||||
return PathBuf::from(env!("HOMEPATH"));
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn tauri_root_path() -> PathBuf {
|
||||
bench_root_path()
|
||||
@@ -192,3 +206,26 @@ pub fn write_json(filename: &str, value: &Value) -> Result<()> {
|
||||
serde_json::to_writer(f, value)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn download_file(url: &str, filename: PathBuf) {
|
||||
if !url.starts_with("http:") && !url.starts_with("https:") {
|
||||
fs::copy(url, filename).unwrap();
|
||||
return;
|
||||
}
|
||||
|
||||
// Downloading with curl this saves us from adding
|
||||
// a Rust HTTP client dependency.
|
||||
println!("Downloading {}", url);
|
||||
let status = Command::new("curl")
|
||||
.arg("-L")
|
||||
.arg("-s")
|
||||
.arg("-o")
|
||||
.arg(&filename)
|
||||
.arg(&url)
|
||||
.status()
|
||||
.unwrap();
|
||||
|
||||
assert!(status.success());
|
||||
assert!(filename.exists());
|
||||
}
|
||||
|
||||
139
tooling/bench/tests/Cargo.lock
generated
139
tooling/bench/tests/Cargo.lock
generated
@@ -167,6 +167,12 @@ dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bumpalo"
|
||||
version = "3.6.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "63396b8a4b9de3f4fdfb320ab6080762242f66a8ef174c49d8e19b674db4cdbe"
|
||||
|
||||
[[package]]
|
||||
name = "bytemuck"
|
||||
version = "1.5.1"
|
||||
@@ -1273,6 +1279,15 @@ dependencies = [
|
||||
"rayon",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "js-sys"
|
||||
version = "0.3.51"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "83bdfbace3a0e81a4253f73b49e960b053e396a11012cbd49b9b74d6a2b67062"
|
||||
dependencies = [
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "kuchiki"
|
||||
version = "0.8.1"
|
||||
@@ -1541,6 +1556,17 @@ dependencies = [
|
||||
"malloc_buf",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "objc-foundation"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1add1b659e36c9607c7aab864a76c7a4c2760cd0cd2e120f3fb8b952c7e22bf9"
|
||||
dependencies = [
|
||||
"block",
|
||||
"objc",
|
||||
"objc_id",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "objc_id"
|
||||
version = "0.1.1"
|
||||
@@ -1997,6 +2023,29 @@ dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rfd"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c1084e570d9ce1890734b33edd8c1a7b7276076f9610fa23a48aa955587da141"
|
||||
dependencies = [
|
||||
"block",
|
||||
"dispatch",
|
||||
"glib-sys",
|
||||
"gobject-sys",
|
||||
"gtk-sys",
|
||||
"js-sys",
|
||||
"lazy_static",
|
||||
"objc",
|
||||
"objc-foundation",
|
||||
"objc_id",
|
||||
"raw-window-handle",
|
||||
"wasm-bindgen",
|
||||
"wasm-bindgen-futures",
|
||||
"web-sys",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ryu"
|
||||
version = "1.0.5"
|
||||
@@ -2344,6 +2393,7 @@ dependencies = [
|
||||
"ignore",
|
||||
"once_cell",
|
||||
"rand 0.8.3",
|
||||
"rfd",
|
||||
"semver",
|
||||
"serde",
|
||||
"serde_json",
|
||||
@@ -2356,7 +2406,6 @@ dependencies = [
|
||||
"tauri-utils",
|
||||
"tempfile",
|
||||
"thiserror",
|
||||
"tinyfiledialogs",
|
||||
"tokio",
|
||||
"uuid",
|
||||
"zip",
|
||||
@@ -2407,6 +2456,7 @@ dependencies = [
|
||||
"tauri-utils",
|
||||
"thiserror",
|
||||
"uuid",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2418,6 +2468,7 @@ dependencies = [
|
||||
"tauri-runtime",
|
||||
"tauri-utils",
|
||||
"uuid",
|
||||
"winapi",
|
||||
"wry",
|
||||
]
|
||||
|
||||
@@ -2519,16 +2570,6 @@ dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tinyfiledialogs"
|
||||
version = "3.3.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c45fb26c3f37d9a8b556e51f6d7f13f685af766017030af56e9247e638aa6194"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tinyvec"
|
||||
version = "1.2.0"
|
||||
@@ -2675,6 +2716,82 @@ version = "0.10.2+wasi-snapshot-preview1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen"
|
||||
version = "0.2.74"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d54ee1d4ed486f78874278e63e4069fc1ab9f6a18ca492076ffb90c5eb2997fd"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"wasm-bindgen-macro",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-backend"
|
||||
version = "0.2.74"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3b33f6a0694ccfea53d94db8b2ed1c3a8a4c86dd936b13b9f0a15ec4a451b900"
|
||||
dependencies = [
|
||||
"bumpalo",
|
||||
"lazy_static",
|
||||
"log",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-futures"
|
||||
version = "0.4.24"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5fba7978c679d53ce2d0ac80c8c175840feb849a161664365d1287b41f2e67f1"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"js-sys",
|
||||
"wasm-bindgen",
|
||||
"web-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro"
|
||||
version = "0.2.74"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "088169ca61430fe1e58b8096c24975251700e7b1f6fd91cc9d59b04fb9b18bd4"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"wasm-bindgen-macro-support",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro-support"
|
||||
version = "0.2.74"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "be2241542ff3d9f241f5e2cb6dd09b37efe786df8851c54957683a49f0987a97"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"wasm-bindgen-backend",
|
||||
"wasm-bindgen-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-shared"
|
||||
version = "0.2.74"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d7cff876b8f18eed75a66cf49b65e7f967cb354a7aa16003fb55dbfd25b44b4f"
|
||||
|
||||
[[package]]
|
||||
name = "web-sys"
|
||||
version = "0.3.51"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e828417b379f3df7111d3a2a9e5753706cae29c41f7c4029ee9fd77f3e09e582"
|
||||
dependencies = [
|
||||
"js-sys",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "webkit2gtk"
|
||||
version = "0.11.0"
|
||||
|
||||
@@ -11,34 +11,37 @@
|
||||
|
||||
<script>
|
||||
window.addEventListener("DOMContentLoaded", (event) => {
|
||||
window.__TAURI__.invoke("tauri", {
|
||||
__tauriModule: "Fs",
|
||||
message: {
|
||||
cmd: "readBinaryFile",
|
||||
path: ".tauri_3mb.json",
|
||||
options: {
|
||||
// home folder
|
||||
dir: 11
|
||||
}
|
||||
},
|
||||
}).then((_data) => {
|
||||
window.__TAURI__.invoke("tauri", {
|
||||
__tauriModule: "Process",
|
||||
window.__TAURI__
|
||||
.invoke("tauri", {
|
||||
__tauriModule: "Fs",
|
||||
message: {
|
||||
cmd: "exit",
|
||||
exitCode: 0,
|
||||
cmd: "readBinaryFile",
|
||||
path: ".tauri_3mb.json",
|
||||
options: {
|
||||
// home folder
|
||||
dir: 11,
|
||||
},
|
||||
},
|
||||
})
|
||||
.then((_data) => {
|
||||
window.__TAURI__.invoke("tauri", {
|
||||
__tauriModule: "Process",
|
||||
message: {
|
||||
cmd: "exit",
|
||||
exitCode: 0,
|
||||
},
|
||||
});
|
||||
})
|
||||
.catch((_error) => {
|
||||
// error
|
||||
window.__TAURI__.invoke("tauri", {
|
||||
__tauriModule: "Process",
|
||||
message: {
|
||||
cmd: "exit",
|
||||
exitCode: 1,
|
||||
},
|
||||
});
|
||||
});
|
||||
}).catch((_error) => {
|
||||
// error
|
||||
window.__TAURI__.invoke("tauri", {
|
||||
__tauriModule: "Process",
|
||||
message: {
|
||||
cmd: "exit",
|
||||
exitCode: 1,
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
@@ -10,7 +10,7 @@ tauri-build = { path = "../../../../../core/tauri-build", features = [ "codegen"
|
||||
[dependencies]
|
||||
serde_json = "1.0"
|
||||
serde = { version = "1.0", features = [ "derive" ] }
|
||||
tauri = { path = "../../../../../core/tauri", features = [] }
|
||||
tauri = { path = "../../../../../core/tauri", features = ["fs-read-binary-file"] }
|
||||
|
||||
[features]
|
||||
default = [ "custom-protocol" ]
|
||||
|
||||
@@ -36,7 +36,10 @@
|
||||
}
|
||||
},
|
||||
"allowlist": {
|
||||
"all": false
|
||||
"all": false,
|
||||
"fs": {
|
||||
"readBinaryFile": true
|
||||
}
|
||||
},
|
||||
"windows": [
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user