【Rust日报】 2019-07-07:snoopy - 一个可高度配置化的多线程网络包嗅探分析工具...

神器 flamer

flamer 是这样一个魔法东西,它可以方便地计算出你代码块的耗时。

基本方法,就是在你的代码/函数头和尾(自动)插入计时代码,最后汇总出一个耗时(报告)。用到了 nightly 的自定义属性,所以暂时只能以 nightly 版运行。看下例子:

extern crate flame;

use std::fs::File;

pub fn main() {
    // Manual `start` and `end`
    flame::start("read file");
    let x = read_a_file();
    flame::end("read file");

    // Time the execution of a closure.  (the result of the closure is returned)
    let y = flame::span_of("database query", || query_database());

    // Time the execution of a block by creating a guard.
    let z = {
        let _guard = flame::start_guard("cpu-heavy calculation");
        cpu_heavy_operations_1();
        // Notes can be used to annotate a particular instant in time.
        flame::note("something interesting happened", None);
        cpu_heavy_operations_2()
    };

    // Dump the report to disk
    flame::dump_html(&mut File::create("flame-graph.html").unwrap()).unwrap();

    // Or read and process the data yourself!
    let spans = flame::spans();

    println!("{} {} {}", x, y, z);
}


------------------------

extern crate flame;
#[macro_use] extern crate flamer;

#[flame]
// The item to apply `flame` to goes here.

Repo

snoopy - 一个可高度配置化的多线程网络包嗅探分析工具

Rust 作这类工具太适合不过了。

➜ sudo snoopy capture run
--------------------
Sniffing  wlp3s0
--------------------


Source IP              | Source Port  | Dest IP                | Dest Port    | Protocol     | Length       | Timestamp            |
------------------------------------------------------------------------------------------------------------------------------------
52.216.185.195         | 443          | 10.20.197.103          | 38522        | Tcp          | 10078        | 1562310108.589373
10.20.197.103          | 38522        | 52.216.185.195         | 443          | Tcp          | 54           | 1562310108.589468
52.216.185.195         | 443          | 10.20.197.103          | 38522        | Tcp          | 10078        | 1562310108.890490
10.20.197.103          | 38522        | 52.216.185.195         | 443          | Tcp          | 54           | 1562310108.890547
52.216.185.195         | 443          | 10.20.197.103          | 38522        | Tcp          | 1486         | 1562310109.197739
10.20.197.103          | 38522        | 52.216.185.195         | 443          | Tcp          | 54           | 1562310109.197795
52.216.185.195         | 443          | 10.20.197.103          | 38522        | Tcp          | 1486         | 1562310109.197841
10.20.197.103          | 38522        | 52.216.185.195         | 443          | Tcp          | 66           | 1562310109.197865
52.216.185.195         | 443          | 10.20.197.103          | 38522        | Tcp          | 2918         | 1562310109.197887
10.20.197.103          | 38522        | 52.216.185.195         | 443          | Tcp          | 74           | 1562310109.197906
52.216.185.195         | 443          | 10.20.197.103          | 38522        | Tcp          | 1486         | 1562310109.197965
10.20.197.103          | 38522        | 52.216.185.195         | 443          | Tcp          | 74           | 1562310109.197984
35.154.102.71          | 443          | 10.20.197.103          | 56572        | Tls          | 160          | 1562310109.262324
10.20.197.103          | 56572        | 35.154.102.71          | 443          | Tcp          | 66           | 1562310109.262383

Repo

yarte - 号称最快的模板渲染引擎

采用 handlebars 语法。作者说它是 Rust 界最快的模板渲染引擎。

Repo

ferrocarril - 把 Ruby on Rails 嵌入 Rust 服务(容器)中运行的尝试

这个项目很有意思。想法很新颖。

Repo


From 日报小组 Mike

日报订阅地址:

独立日报订阅地址:

  • Telgram Channel

  • 阿里云语雀订阅

  • Steemit

  • GitHub

社区学习交流平台订阅:

  • Rust.cc论坛: 支持rss

  • Rust Force: 支持rss

  • 微信公众号:Rust语言学习交流

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值