forked from rust-postgres/rust-postgres
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbench.rs
More file actions
29 lines (23 loc) · 812 Bytes
/
Copy pathbench.rs
File metadata and controls
29 lines (23 loc) · 812 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
extern crate test;
extern crate postgres;
use test::Bencher;
use postgres::{Connection, SslMode};
#[bench]
fn bench_naiive_execute(b: &mut test::Bencher) {
let conn = Connection::connect("postgres://postgres@localhost", &SslMode::None).unwrap();
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) {
let conn = Connection::connect("postgres://postgres@localhost", &SslMode::None).unwrap();
conn.execute("CREATE TEMPORARY TABLE foo (id INT)", &[]).unwrap();
b.iter(|| {
conn.execute("UPDATE foo SET id = 1", &[]).unwrap()
});
}