New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
After using rbatis 4, it was found that it is not compatible with the criterion bench #464
Comments
After using rbatis 4, I found that it is not compatible with criterion bench. Can you help me find out what the problem is? The relevant package versions are as follows:
The bench code is as follows: use criterion::{Criterion, BenchmarkId, criterion_group, criterion_main};
use rbatis::{RBatis, executor::RBatisConnExecutor};
use rbdc_sqlite::Driver;
async fn init_connection() -> RBatisConnExecutor {
let rb = RBatis::new();
rb.init(Driver{},"sqlite::memory:").unwrap();
rb.exec(r#"
CREATE TABLE test_user (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(255) NULL,
age INT NULL
)"#,
vec![]
).await.unwrap();
rb.exec("INSERT INTO test_user (name, age) VALUES ('huanglan', 10)", vec![]).await.unwrap();
rb.exec("INSERT INTO test_user (name, age) VALUES ('zhanglan', 21)", vec![]).await.unwrap();
rb.exec("INSERT INTO test_user (name, age) VALUES ('zhangsan', 35)", vec![]).await.unwrap();
rb.exec("INSERT INTO test_user (name, age) VALUES ('a4', 12)", vec![]).await.unwrap();
rb.exec("INSERT INTO test_user (name, age) VALUES ('a5', 21)", vec![]).await.unwrap();
rb.exec("INSERT INTO test_user (name, age) VALUES ('a6', 22)", vec![]).await.unwrap();
rb.exec("INSERT INTO test_user (name, age) VALUES ('a7', 24)", vec![]).await.unwrap();
rb.exec("INSERT INTO test_user (name, age) VALUES ('a8', 31)", vec![]).await.unwrap();
rb.exec("INSERT INTO test_user (name, age) VALUES ('a9', 33)", vec![]).await.unwrap();
let a = rb.acquire().await.unwrap();
a
}
fn describe_trivial(c: &mut Criterion) {
let runtime = tokio::runtime::Runtime::new().unwrap();
let _db = runtime.block_on(init_connection());
let size = 1;
c.bench_with_input(
BenchmarkId::new("select", "trivial"),
&size,
move |b, _db_ref| {
// Insert a call to `to_async` to convert the bench to async mode.
// The timing loops are the same as with the normal bencher.
b.to_async(&runtime).iter(||
// do_describe_trivial(db_ref)
async {}
);
},
);
}
criterion_group!(
benches,
describe_trivial,
);
criterion_main!(benches); After executing cargo bench, an exception will be reported thread 'main' panicked at /home/evan/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/rbdc-4.5.9/src/pool/conn_manager.rs:21:9:
there is no reactor running, must be called from the context of a Tokio 1.x runtime
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at /home/evan/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/rbdc-4.5.9/src/pool/conn_manager.rs:21:9:
there is no reactor running, must be called from the context of a Tokio 1.x runtime
stack backtrace:
0: 0x55a0ae92c730 - std::backtrace_rs::backtrace::libunwind::trace::h0533452212810ad0
at /rustc/58e967a9cc3bd39122e8cb728e8cec6e3a4eeef2/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
1: 0x55a0ae92c730 - std::backtrace_rs::backtrace::trace_unsynchronized::heac64938397c8c70
at /rustc/58e967a9cc3bd39122e8cb728e8cec6e3a4eeef2/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
2: 0x55a0ae92c730 - std::sys_common::backtrace::_print_fmt::hb23dc0a3b2464f20
at /rustc/58e967a9cc3bd39122e8cb728e8cec6e3a4eeef2/library/std/src/sys_common/backtrace.rs:67:5
3: 0x55a0ae92c730 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h019008fb57527154
at /rustc/58e967a9cc3bd39122e8cb728e8cec6e3a4eeef2/library/std/src/sys_common/backtrace.rs:44:22
4: 0x55a0ae7457bc - core::fmt::rt::Argument::fmt::hf0ca3042505afdbe
at /rustc/58e967a9cc3bd39122e8cb728e8cec6e3a4eeef2/library/core/src/fmt/rt.rs:138:9
5: 0x55a0ae7457bc - core::fmt::write::h64998bddcdaf5f5a
... |
我不知道 criterion bench是怎么用的,你可以先查一下资料 |
I don’t know how to use criterion bench. You can check the information first. |
用了下 rbatis 4 后,发现不兼容 criterion bench,能帮忙看下是什么问题吗?
相关包版本如下:
bench 代码如下:
执行 cargo bench 后,会报异常
The text was updated successfully, but these errors were encountered: