diff --git a/.cargo/config b/.cargo/config index ebbfda8..40220e5 100644 --- a/.cargo/config +++ b/.cargo/config @@ -1,5 +1,9 @@ [build] target = "wasm32-unknown-unknown" +[target.'cfg(target_arch = "wasm32")'] +runner = 'wasm-bindgen-test-runner' + + [profile.release] lto = true diff --git a/Cargo.lock b/Cargo.lock index 999865d..c9256fc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -105,7 +105,7 @@ checksum = "83137067e3a2a6a06d67168e49e68a0957d215410473a740cea95a2425c0b7c6" dependencies = [ "async-io", "blocking", - "cfg-if 1.0.0", + "cfg-if", "event-listener", "futures-lite", "libc", @@ -263,12 +263,6 @@ version = "1.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22a9137b95ea06864e018375b72adfb7db6e6f68cfc8df5a04d00288050485ee" -[[package]] -name = "cfg-if" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" - [[package]] name = "cfg-if" version = "1.0.0" @@ -290,7 +284,7 @@ version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "wasm-bindgen", ] @@ -329,7 +323,7 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "738c290dfaea84fc1ca15ad9c168d083b05a714e1efddd8edaab678dc28d2836" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", ] [[package]] @@ -338,7 +332,7 @@ version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cfcae03edb34f947e64acdb1c33ec169824e20657e9ecb61cef6c8c74dcb8120" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "lazy_static", ] @@ -469,7 +463,7 @@ version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e6988e897c1c9c485f43b47a529cef42fde0547f9d8d41a7062518f1d8fc53f" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "crc32fast", "libc", "miniz_oxide", @@ -488,7 +482,7 @@ dependencies = [ "base64", "built", "bytes", - "cfg-if 1.0.0", + "cfg-if", "derive_builder", "dirs", "event-listener", @@ -535,7 +529,6 @@ dependencies = [ "wasm-bindgen-futures", "wasm-bindgen-test", "web-sys", - "wee_alloc", "ws_stream_wasm", ] @@ -577,7 +570,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b608e8f4a6c3d28ff15981ebe185b20da6131982f2ff560a4efc90285896fda" dependencies = [ "bytes", - "cfg-if 1.0.0", + "cfg-if", "content_inspector", "crc32c", "eyre", @@ -602,7 +595,7 @@ dependencies = [ "async-net", "async-std", "async-trait", - "cfg-if 1.0.0", + "cfg-if", "fluvio-wasm-timer", "futures-lite", "futures-util", @@ -667,7 +660,7 @@ dependencies = [ "async-lock", "async-trait", "bytes", - "cfg-if 1.0.0", + "cfg-if", "event-listener", "fluvio-future", "fluvio-protocol", @@ -885,7 +878,7 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "418d37c8b1d42553c93648be529cb70f920d3baf8ef469b74b9638df426e0b4c" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "libc", "wasi", ] @@ -941,7 +934,7 @@ version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "js-sys", "wasm-bindgen", "web-sys", @@ -998,7 +991,7 @@ version = "0.4.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6389c490849ff5bc16be905ae24bc913a9c8892e19b2341dbc175e14c341c2b8" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "value-bag", ] @@ -1023,12 +1016,6 @@ version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" -[[package]] -name = "memory_units" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8452105ba047068f40ff7093dd1d9da90898e63dd61736462e9cdda6a90ad3c3" - [[package]] name = "miniz_oxide" version = "0.4.4" @@ -1062,7 +1049,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c7ae222234c30df141154f159066c5093ff73b63204dcda7121eb082fc56a95" dependencies = [ "bitflags", - "cfg-if 1.0.0", + "cfg-if", "foreign-types", "libc", "once_cell", @@ -1115,7 +1102,7 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "instant", "libc", "redox_syscall", @@ -1189,7 +1176,7 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "685404d509889fade3e86fe3a5803bca2ec09b0c0778d5ada6ec8bf7a8de5259" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "libc", "log", "wepoll-ffi", @@ -1497,7 +1484,7 @@ version = "0.1.34" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5d0ecdcb44a79f0fe9844f0c4f33a342cbcbb5117de8001e6ba0dc2351327d09" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "pin-project-lite", "tracing-attributes", "tracing-core", @@ -1552,7 +1539,7 @@ version = "1.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ee73e6e4924fe940354b8d4d98cad5231175d615cd855b758adc658c0aac6a0" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "static_assertions", ] @@ -1635,7 +1622,7 @@ version = "0.2.80" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "27370197c907c55e3f1a9fbe26f44e937fe6451368324e009cba39e139dc08ad" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "serde", "serde_json", "wasm-bindgen-macro", @@ -1662,7 +1649,7 @@ version = "0.4.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6f741de44b75e14c35df886aff5f1eb73aa114fa5d4d00dcd37b5e01259bf3b2" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "futures-core", "js-sys", "wasm-bindgen", @@ -1732,18 +1719,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "wee_alloc" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbb3b5a6b2bb17cb6ad44a2e68a43e8d2722c997da10e928665c72ec6c0a0b8e" -dependencies = [ - "cfg-if 0.1.10", - "libc", - "memory_units", - "winapi", -] - [[package]] name = "wepoll-ffi" version = "0.1.2" diff --git a/Cargo.toml b/Cargo.toml index a637047..59ea3e8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,12 +34,6 @@ base64 = "0.13.0" # code size when deploying. console_error_panic_hook = { version = "0.1.7" } -# `wee_alloc` is a tiny allocator for wasm that is only ~1K in code size -# compared to the default allocator's ~10K. It is slower than the default -# allocator, however. -# -# Unfortunately, `wee_alloc` requires nightly Rust when targeting wasm for now. -wee_alloc = { version = "0.4.5" } thiserror = "1.0.31" [dev-dependencies] diff --git a/Makefile b/Makefile index 258003e..6a42180 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,8 @@ build-dev: test: install-wasm-pack WASM_BINDGEN_TEST_TIMEOUT=30 wasm-pack test --firefox --headless + # Using cargo test with wasm-bindgen-test-runner allows to run specific tests + #NO_HEADLESS=1 GECKODRIVER=$(which geckodriver) cargo test js_tests::simple build-fluvio-websocket-proxy: RUST_LOG=debug cargo build --manifest-path ./fluvio-websocket-proxy/Cargo.toml --target $(PROXY_TARGET) diff --git a/src/lib.rs b/src/lib.rs index 5669984..3e8d200 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -20,11 +20,6 @@ pub use offset::Offset; pub use producer::TopicProducer; pub use record::Record; -// When the `wee_alloc` feature is enabled, use `wee_alloc` as the global -// allocator. -#[global_allocator] -static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT; - use js_sys::Reflect; use wasm_bindgen::convert::FromWasmAbi; use wasm_bindgen::JsValue; diff --git a/tests/js/simple/simple.js b/tests/js/simple/simple.js index 67ca30b..8db5060 100644 --- a/tests/js/simple/simple.js +++ b/tests/js/simple/simple.js @@ -2,6 +2,7 @@ import { Offset, Fluvio } from "../../../../../wasm-bindgen-test"; import { createUUID } from "../utils.js"; const topic = createUUID(); +const NUMB_RECORDS = 100; var fluvio; export const setup = async () => { @@ -41,13 +42,13 @@ export const test = async () => { let count = 0; const userAgent = navigator.userAgent; - while (count < 100) { + while (count < NUMB_RECORDS) { count++; let in_record = `${count}-${userAgent}`; await producer.send("", in_record); } count = 0; - while (count < 100) { + while (count < NUMB_RECORDS) { count++; let in_record = `${count}-${userAgent}`; let next = await stream.next(); diff --git a/tests/js_tests.rs b/tests/js_tests.rs index d65de43..cf92735 100644 --- a/tests/js_tests.rs +++ b/tests/js_tests.rs @@ -33,12 +33,14 @@ async fn simple() { .map_err(FluvioError::try_from) .expect("Setup failed"); web_sys::console::time_end_with_label("simple-setup"); + web_sys::console::profile_0(); web_sys::console::time_with_label("simple-test"); test() .await .map_err(FluvioError::try_from) .expect("Test failed"); web_sys::console::time_end_with_label("simple-test"); + web_sys::console::profile_end_0(); web_sys::console::time_with_label("simple-teardown"); teardown() .await