2016-10-04 19:22:10 +00:00
|
|
|
#![feature(test)]
|
2014-12-02 06:24:31 +00:00
|
|
|
extern crate test;
|
|
|
|
extern crate postgres;
|
|
|
|
|
2016-10-04 19:22:10 +00:00
|
|
|
use postgres::{Connection, TlsMode};
|
2014-12-02 06:24:31 +00:00
|
|
|
|
|
|
|
#[bench]
|
|
|
|
fn bench_naiive_execute(b: &mut test::Bencher) {
|
2016-10-04 19:22:10 +00:00
|
|
|
let conn = Connection::connect("postgres://postgres@localhost", TlsMode::None).unwrap();
|
2014-12-02 06:24:31 +00:00
|
|
|
conn.execute("CREATE TEMPORARY TABLE foo (id INT)", &[]).unwrap();
|
|
|
|
|
|
|
|
b.iter(|| {
|
|
|
|
let stmt = conn.prepare("UPDATE foo SET id = 1").unwrap();
|
|
|
|
let out = stmt.execute(&[]).unwrap();
|
|
|
|
stmt.finish().unwrap();
|
|
|
|
out
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
#[bench]
|
|
|
|
fn bench_execute(b: &mut test::Bencher) {
|
2016-10-04 19:22:10 +00:00
|
|
|
let conn = Connection::connect("postgres://postgres@localhost", TlsMode::None).unwrap();
|
2014-12-02 06:24:31 +00:00
|
|
|
conn.execute("CREATE TEMPORARY TABLE foo (id INT)", &[]).unwrap();
|
|
|
|
|
|
|
|
b.iter(|| {
|
|
|
|
conn.execute("UPDATE foo SET id = 1", &[]).unwrap()
|
|
|
|
});
|
|
|
|
}
|