-
Notifications
You must be signed in to change notification settings - Fork 723
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(bindings): ConfigPool should always yield associated connections (#…
- Loading branch information
Showing
4 changed files
with
148 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use criterion::{criterion_group, criterion_main, Criterion}; | ||
use s2n_tls::{ | ||
config::Config, | ||
connection::Builder, | ||
enums::Mode, | ||
pool::{ConfigPool, ConfigPoolBuilder, PooledConnection}, | ||
}; | ||
use std::sync::Arc; | ||
|
||
fn connection_wipe(connection_pool: &Arc<ConfigPool>) { | ||
// get a connection from the pool | ||
let conn = PooledConnection::new(connection_pool).unwrap(); | ||
// "drop" the connection, wiping it and returning it to the pool | ||
drop(conn); | ||
} | ||
|
||
fn connection_new(config: &Config) { | ||
let conn = config | ||
.build_connection(s2n_tls::enums::Mode::Server) | ||
.unwrap(); | ||
drop(conn); | ||
} | ||
|
||
fn connection_creation(c: &mut Criterion) { | ||
let mut group = c.benchmark_group("Connection Creation"); | ||
let config = s2n_tls::config::Builder::new().build().unwrap(); | ||
let connection_pool = ConfigPoolBuilder::new(Mode::Server, config.clone()).build(); | ||
|
||
group.bench_function("connection reuse", |b| { | ||
b.iter(|| connection_wipe(&connection_pool)); | ||
}); | ||
|
||
group.bench_function("connection allocation", |b| { | ||
b.iter(|| connection_new(&config)); | ||
}); | ||
|
||
group.finish(); | ||
} | ||
|
||
criterion_group!(benches, connection_creation); | ||
criterion_main!(benches); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters