mirror of
https://github.com/MercuryWorkshop/epoxy-tls.git
synced 2025-05-13 06:20:02 -04:00
remove unnecessary mut self references
This commit is contained in:
parent
619a2a61c7
commit
fa2b84d646
6 changed files with 55 additions and 19 deletions
|
@ -5,6 +5,7 @@
|
|||
);
|
||||
|
||||
const should_feature_test = (new URL(window.location.href)).searchParams.has("feature_test");
|
||||
const should_parallel_test = (new URL(window.location.href)).searchParams.has("parallel_test");
|
||||
const should_perf_test = (new URL(window.location.href)).searchParams.has("perf_test");
|
||||
const should_ws_test = (new URL(window.location.href)).searchParams.has("ws_test");
|
||||
|
||||
|
@ -36,6 +37,40 @@
|
|||
console.warn(url, resp, Object.fromEntries(resp.headers));
|
||||
console.warn(await resp.text());
|
||||
}
|
||||
} else if (should_parallel_test) {
|
||||
const test_mux = async (url) => {
|
||||
const t0 = performance.now();
|
||||
await epoxy_client.fetch(url);
|
||||
const t1 = performance.now();
|
||||
return t1 - t0;
|
||||
};
|
||||
|
||||
const test_native = async (url) => {
|
||||
const t0 = performance.now();
|
||||
await fetch(url);
|
||||
const t1 = performance.now();
|
||||
return t1 - t0;
|
||||
};
|
||||
|
||||
const num_tests = 10;
|
||||
|
||||
let total_mux = 0;
|
||||
await Promise.all([...Array(num_tests).keys()].map(async i=>{
|
||||
log(`running mux test ${i}`);
|
||||
return await test_mux("https://httpbin.org/get");
|
||||
})).then((vals)=>{total_mux = vals.reduce((acc, x) => acc + x, 0)});
|
||||
total_mux = total_mux / num_tests;
|
||||
|
||||
let total_native = 0;
|
||||
await Promise.all([...Array(num_tests).keys()].map(async i=>{
|
||||
log(`running native test ${i}`);
|
||||
return await test_native("https://httpbin.org/get");
|
||||
})).then((vals)=>{total_native = vals.reduce((acc, x) => acc + x, 0)});
|
||||
total_native = total_native / num_tests;
|
||||
|
||||
log(`avg mux (10) took ${total_mux} ms or ${total_mux / 1000} s`);
|
||||
log(`avg native (10) took ${total_native} ms or ${total_native / 1000} s`);
|
||||
log(`mux - native: ${total_mux - total_native} ms or ${(total_mux - total_native) / 1000} s`);
|
||||
} else if (should_perf_test) {
|
||||
const test_mux = async (url) => {
|
||||
const t0 = performance.now();
|
||||
|
|
|
@ -173,7 +173,7 @@ impl EpoxyClient {
|
|||
})
|
||||
}
|
||||
|
||||
async fn get_http_io(&mut self, url: &Uri) -> Result<EpxStream, JsError> {
|
||||
async fn get_http_io(&self, url: &Uri) -> Result<EpxStream, JsError> {
|
||||
let url_host = url.host().replace_err("URL must have a host")?;
|
||||
let url_port = utils::get_url_port(url)?;
|
||||
let channel = self
|
||||
|
@ -203,7 +203,7 @@ impl EpoxyClient {
|
|||
}
|
||||
|
||||
async fn send_req(
|
||||
&mut self,
|
||||
&self,
|
||||
req: http::Request<HttpBody>,
|
||||
should_redirect: bool,
|
||||
) -> Result<(hyper::Response<Incoming>, Uri, bool), JsError> {
|
||||
|
@ -231,7 +231,7 @@ impl EpoxyClient {
|
|||
// shut up
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub async fn connect_ws(
|
||||
&mut self,
|
||||
&self,
|
||||
onopen: Function,
|
||||
onclose: Function,
|
||||
onerror: Function,
|
||||
|
@ -247,7 +247,7 @@ impl EpoxyClient {
|
|||
}
|
||||
|
||||
pub async fn fetch(
|
||||
&mut self,
|
||||
&self,
|
||||
url: String,
|
||||
options: Object,
|
||||
) -> Result<web_sys::Response, JsError> {
|
||||
|
|
|
@ -30,7 +30,7 @@ impl EpxWebSocket {
|
|||
// shut up
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub async fn connect(
|
||||
tcp: &mut EpoxyClient,
|
||||
tcp: &EpoxyClient,
|
||||
onopen: Function,
|
||||
onclose: Function,
|
||||
onerror: Function,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue