Skip to content

Commit

Permalink
chore: save progress
Browse files Browse the repository at this point in the history
  • Loading branch information
Fyko committed Oct 10, 2023
1 parent 87b2f3e commit a3beba3
Show file tree
Hide file tree
Showing 12 changed files with 1,015 additions and 71 deletions.
15 changes: 15 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion example/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@ serde.workspace = true
serde_json.workspace = true
scylla.workspace = true
scyllax = { path = "../scyllax" }
tokio.workspace = true
tokio = { version = "1", features = ["full"] }
tracing.workspace = true
tracing-subscriber.workspace = true
uuid.workspace = true
tokio-stream = "0.1.14"
futures-util = "0.3.28"
futures = "0.3.28"
rayon = "1.8.0"

[features]
default = ["integration"]
Expand Down
33 changes: 22 additions & 11 deletions example/benches/bench.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
//! benches
use example::entities::person::{self, queries::PersonQueries};
use scyllax::prelude::{create_session, Executor};
use std::sync::Arc;

use example::entities::{
person::{self, queries::PersonQueries},
PersonEntity,
};
use scyllax::prelude::{create_session, Executor};
use tracing_subscriber::prelude::*;

async fn test_select(executor: Arc<Executor<PersonQueries>>) {
async fn test_select(executor: Arc<Executor<PersonQueries>>) -> Option<PersonEntity> {
let query = person::queries::GetPersonByEmail {
email: "[email protected]".to_string(),
};

let _ = executor
executor
.execute_read(query)
.await
.expect("person not found");
.expect("person not found")
}

const RUNS: usize = 100_000;
const RUNS: usize = 1000;

#[tokio::main]
#[tokio::main(flavor = "multi_thread", worker_threads = 10)]
async fn main() -> Result<(), anyhow::Error> {
tracing_subscriber::registry()
.with(tracing_subscriber::EnvFilter::from_default_env())
Expand All @@ -30,13 +34,20 @@ async fn main() -> Result<(), anyhow::Error> {

let session = create_session(known_nodes, default_keyspace).await?;
let executor = Arc::new(Executor::<PersonQueries>::new(Arc::new(session)).await?);

let start = std::time::Instant::now();
for _ in 0..RUNS {
test_select(executor.clone()).await;

let futures: Vec<_> = (0..RUNS)
.map(|_| {
let executor = executor.clone();
tokio::spawn(test_select(executor))
})
.collect();
let mut res = Vec::with_capacity(futures.len());
for f in futures.into_iter() {
res.push(f.await.unwrap());
}
let end = std::time::Instant::now();

let end = std::time::Instant::now();
println!("elapsed: {:#?}", end - start);
println!("per run: {:?}", (end - start) / RUNS as u32);

Expand Down
Loading

0 comments on commit a3beba3

Please sign in to comment.