record my code tests
-
std list容器的拼接,裁剪
-
c++ 实现类似rust的栈上move,只有在最终move处析构才会触发最初设置的回调函数
-
c++相互引用例子,必须要将实现放到c文件中, 头文件中互相向前声明
-
匹配字符串,%匹配任意数量字符,_匹配单个字符
-
cpp 在函数内写函数只有lambada,但是不能递归调用,可以写结构体,结构体的函数可以被递归调用。
-
cpp list拼接demo
-
字符串转数字(浮点 或 整形)
-
实现简单的reactor epoll 模式,并做并发性能测试
1.首先测试std有锁和无锁的连续写(锁没有影响
2.测试加入tokio 通道,单个thread worker写
fn tokio_worker_write(c: &mut Criterion){
let mut f =touch();
let (t,mut r)=tokio::sync::mpsc::channel(10);
std::thread::spawn(
move ||{
loop{
let res:tokio::sync::oneshot::Sender<()>=r.blocking_recv().unwrap();
f.write("hhhh".as_bytes());
res.send(()).unwrap();
}
});
std::thread::sleep(std::time::Duration::from_secs(5));
c.bench_function("tokio_worker_write", |b| b.iter(|| {
let (t1,r1)=tokio::sync::oneshot::channel();
t.blocking_send(t1);
r1.blocking_recv();
}));
}
可以发现。通道通信耗费挺多时间的。毕竟通道是用于并发环境下,