Skip to content

Commit

Permalink
Merge branch 'main' into workspace_improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisGariepy committed Feb 8, 2023
2 parents eea13d8 + 282cada commit abea66b
Show file tree
Hide file tree
Showing 48 changed files with 10,338 additions and 11,935 deletions.
502 changes: 280 additions & 222 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion benches/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ cornucopia_async = { path = "../crates/client_async" }
criterion = { version = "0.4.0", features = ["html_reports"] }

# async
tokio = { version = "1.22.0", features = ["full"] }
tokio = { version = "1.24.2", features = ["full"] }
futures = "0.3.25"

# rust-postgres interaction
Expand Down
8 changes: 5 additions & 3 deletions benches/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ fn bench(c: &mut Criterion) {
cornucopia::container::setup(false).unwrap();
let client = &mut cornucopia_conn().unwrap();

cornucopia::load_schema(client, vec!["../test_codegen/schema.sql".into()]).unwrap();
cornucopia::load_schema(client, &["../codegen_test/schema.sql"]).unwrap();
c.bench_function("codegen_sync", |b| {
b.iter(|| {
cornucopia::generate_live(
client,
"../test_codegen/queries",
None,
CodegenSettings {
is_async: false,
gen_sync: true,
gen_async: false,
derive_ser: true,
},
)
Expand All @@ -28,7 +29,8 @@ fn bench(c: &mut Criterion) {
"../test_codegen/queries",
None,
CodegenSettings {
is_async: true,
gen_sync: true,
gen_async: false,
derive_ser: true,
},
)
Expand Down
30 changes: 12 additions & 18 deletions benches/execution/cornucopia_benches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ use criterion::Bencher;
use futures::executor::block_on;
use tokio_postgres::Client;

use self::generated_async::queries::bench::{
comments_by_post_id, insert_user, post_by_user_ids, select_complex, users, Comment, Post, User,
use self::generated::queries::bench::{
async_::{comments_by_post_id, insert_user, post_by_user_ids, select_complex, users},
Comment, Post, User,
};

mod generated_async;
mod generated_sync;
mod generated;

pub fn bench_trivial_query(b: &mut Bencher, client: &Client) {
let mut stmt = users();
Expand Down Expand Up @@ -49,7 +49,7 @@ pub fn bench_insert(b: &mut Bencher, client: &mut Client, size: usize) {
block_on(async {
let tx = client.transaction().await.unwrap();
for x in 0..size {
stmt.bind(&tx, &format!("User {}", x).as_str(), &Some("hair_color"))
stmt.bind(&tx, &format!("User {x}").as_str(), &Some("hair_color"))
.await
.unwrap();
}
Expand Down Expand Up @@ -101,8 +101,7 @@ pub fn loading_associations_sequentially(b: &mut Bencher, client: &Client) {
}

users
.into_iter()
.map(|(_, users_with_post_and_comment)| users_with_post_and_comment)
.into_values()
.collect::<Vec<(User, Vec<(Post, Vec<Comment>)>)>>()
})
})
Expand All @@ -114,9 +113,9 @@ pub mod sync {
use criterion::Bencher;
use postgres::Client;

use super::generated_sync::queries::bench::{
comments_by_post_id, insert_user, post_by_user_ids, select_complex, users, Comment, Post,
User,
use super::generated::queries::bench::{
sync::{comments_by_post_id, insert_user, post_by_user_ids, select_complex, users},
Comment, Post, User,
};
pub fn bench_trivial_query(b: &mut Bencher, client: &mut Client) {
let mut stmt = users();
Expand Down Expand Up @@ -152,12 +151,8 @@ pub mod sync {
b.iter(|| {
let mut tx = client.transaction().unwrap();
for x in 0..size {
stmt.bind(
&mut tx,
&format!("User {}", x).as_str(),
&Some("hair_color"),
)
.unwrap();
stmt.bind(&mut tx, &format!("User {x}").as_str(), &Some("hair_color"))
.unwrap();
}
tx.commit().unwrap();
})
Expand Down Expand Up @@ -201,8 +196,7 @@ pub mod sync {
}

users
.into_iter()
.map(|(_, users_with_post_and_comment)| users_with_post_and_comment)
.into_values()
.collect::<Vec<(User, Vec<(Post, Vec<Comment>)>)>>()
})
}
Expand Down
Loading

0 comments on commit abea66b

Please sign in to comment.