mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-26 03:11:36 +08:00
Revert "Remove usage of unstable library feature 'duration'"
This reverts commit 9c415f9c9e
.
This commit is contained in:
parent
50bfba1e1d
commit
a2327fb048
@ -50,6 +50,7 @@
|
|||||||
//! }
|
//! }
|
||||||
//! }
|
//! }
|
||||||
//! ```
|
//! ```
|
||||||
|
#![cfg_attr(test, feature(duration))]
|
||||||
extern crate libc;
|
extern crate libc;
|
||||||
extern crate libsqlite3_sys as ffi;
|
extern crate libsqlite3_sys as ffi;
|
||||||
#[macro_use] extern crate bitflags;
|
#[macro_use] extern crate bitflags;
|
||||||
|
10
src/trace.rs
10
src/trace.rs
@ -83,17 +83,19 @@ mod test {
|
|||||||
super::config_log(None).unwrap();
|
super::config_log(None).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" fn trace_callback(_: *mut ::libc::c_void, sql: *const ::libc::c_char) {
|
extern "C" fn profile_callback(_: *mut ::libc::c_void, sql: *const ::libc::c_char, nanoseconds: u64) {
|
||||||
|
use std::time::Duration;
|
||||||
unsafe {
|
unsafe {
|
||||||
let c_slice = ::std::ffi::CStr::from_ptr(sql).to_bytes();
|
let c_slice = ::std::ffi::CStr::from_ptr(sql).to_bytes();
|
||||||
let _ = writeln!(::std::io::stderr(), "TRACE: {:?}", ::std::str::from_utf8(c_slice));
|
let d = Duration::from_millis(nanoseconds / 1_000_000);
|
||||||
|
let _ = writeln!(::std::io::stderr(), "PROFILE: {:?} ({})", ::std::str::from_utf8(c_slice), d);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_trace() {
|
fn test_profile() {
|
||||||
let mut db = SqliteConnection::open_in_memory().unwrap();
|
let mut db = SqliteConnection::open_in_memory().unwrap();
|
||||||
db.trace(Some(trace_callback));
|
db.profile(Some(profile_callback));
|
||||||
db.execute_batch("PRAGMA application_id = 1").unwrap();
|
db.execute_batch("PRAGMA application_id = 1").unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user