From 18d117e4b460b6010ac5d7112d247def9cfbe749 Mon Sep 17 00:00:00 2001 From: Vlad Beffa <6473744+vbeffa@users.noreply.github.com> Date: Tue, 13 Jul 2021 21:52:33 +0000 Subject: [PATCH] WIP: Redo ws support (#7) * release: v0.5.4 * Fix infinite compile loop regression from recursive Lazy reference * release: v0.5.5 * Improve root README.md and sqlx-cli/README.md (#1262) * readme: Fix inconsistent list style * readme: Improve text alignment * readme: Fix missing links * readme: Consistently use code formatting for runtime & TLS crates and dedup links * readme: Add SQLx is not an ORM section * readme: Improve documentation about offline mode * Rename _expr to expr (#1264) * redo changes from abhijeetbhagat:ws-support * wip * remove runtime-wasm-bindgen feature * remove runtime-wasm-bindgen feature * removed unneeded dependency Co-authored-by: Ryan Leckey Co-authored-by: toshokan Co-authored-by: Jonas Platte Co-authored-by: Rohan Sharma --- sqlx-bench/Cargo.toml | 5 ++++ sqlx-bench/benches/wasm_querying.rs | 26 +++++++++++++++++++ sqlx-rt/src/lib.rs | 3 +-- .../src/pg_types_tests_ipnetwork.rs | 1 - 4 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 sqlx-bench/benches/wasm_querying.rs diff --git a/sqlx-bench/Cargo.toml b/sqlx-bench/Cargo.toml index 0b288ca892..167311ac53 100644 --- a/sqlx-bench/Cargo.toml +++ b/sqlx-bench/Cargo.toml @@ -45,3 +45,8 @@ sqlx-rt = { version = "0.5", path = "../sqlx-rt", default-features = false } name = "pg_pool" harness = false required-features = ["postgres"] + +[[bench]] +name = "wasm_querying" +harness = false +required-features = ["postgres"] diff --git a/sqlx-bench/benches/wasm_querying.rs b/sqlx-bench/benches/wasm_querying.rs new file mode 100644 index 0000000000..0c6e89facd --- /dev/null +++ b/sqlx-bench/benches/wasm_querying.rs @@ -0,0 +1,26 @@ +use criterion::{black_box, criterion_group, criterion_main, Criterion}; +use sqlx::Row; +use sqlx::{postgres::PgRow, Connection}; +use sqlx::{Database, PgConnection, Postgres}; +use sqlx_rt::spawn; + +const URL: &str = "postgresql://paul:pass123@127.0.0.1:8080/jetasap_dev"; + +fn select() { + spawn(async { + let mut conn = ::Connection::connect(URL) + .await + .unwrap(); + + let airports = sqlx::query("select * from airports") + .fetch_all(&mut conn) + .await; + }); +} + +fn criterion_benchmark(c: &mut Criterion) { + c.bench_function("fib 20", |b| b.iter(|| select())); +} + +criterion_group!(benches, criterion_benchmark); +criterion_main!(benches); diff --git a/sqlx-rt/src/lib.rs b/sqlx-rt/src/lib.rs index 527b66c580..9b82302d99 100644 --- a/sqlx-rt/src/lib.rs +++ b/sqlx-rt/src/lib.rs @@ -5,8 +5,7 @@ feature = "runtime-actix-rustls", feature = "runtime-async-std-rustls", feature = "runtime-tokio-rustls", - ) -))] +)))] compile_error!( "one of the features ['runtime-actix-native-tls', 'runtime-async-std-native-tls', \ 'runtime-tokio-native-tls', 'runtime-actix-rustls', 'runtime-async-std-rustls', \ diff --git a/sqlx-wasm-test/src/pg_types_tests_ipnetwork.rs b/sqlx-wasm-test/src/pg_types_tests_ipnetwork.rs index 206a15ff49..71e18bff8b 100644 --- a/sqlx-wasm-test/src/pg_types_tests_ipnetwork.rs +++ b/sqlx-wasm-test/src/pg_types_tests_ipnetwork.rs @@ -50,4 +50,3 @@ test_type!(ipnetwork_vec>(Postgres, "8.8.8.8/24".parse::().unwrap() ] )); -