7 个版本
| 0.0.8 | 2020年11月13日 | 
|---|---|
| 0.0.7 | 2020年11月7日 | 
| 0.0.1 | 2020年10月31日 | 
#599 在 并发 分类中
58KB
373 行
概述
一个小工具,用于测试构建并发应用的不同方法。
先决条件
- cargo- https://rust-lang.net.cn/tools/install
- python3.6+with- matplotlib
它在当前目录生成以下文件
- latency_histogram_{name}.png- X轴延迟(毫秒),Y轴 - 桶计数 
- latency_percentiles_{name}.png- X轴 - 0..100. Y轴 - 延迟百分位数(毫秒) 
- latency_timeline_{name}.png- X轴 - 时间线(秒),Y轴 - 延迟(毫秒),p50,p90 和 p99 
- request_rate_{name}.png- X轴 - 时间线(秒),Y轴 - 有效RPS(仅成功) 
其中 {name} 是 --name(或 -N)参数值。
如果Python 3二进制文件不在 /usr/bin/python3 中,您可能需要使用 --pythob/-p 参数指定 python3 二进制文件。例如。
concurrency-demo-benchmarks --name async_30s \
                            --rate 1000 \
                            --num_req 100000 \
                            --latency "20ms*9,30s" \
                            --python /somewhere/else/python3 \
                            async
安装
cargo install concurrency-demo-benchmarks  
运行批处理/原子/互斥量递增基准测试
git clone https://github.com/xnuter/concurrency-demo-benchmarks.git
cargo bench
命令行选项
A tool to model sync vs async processing for a network service
USAGE:
    concurrency-demo-benchmarks [OPTIONS] --name <NAME> --rate <RATE> --num_req <NUM_REQUESTS> --latency <LATENCY_DISTRIBUTION> [SUBCOMMAND]
FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information
OPTIONS:
    -l, --latency <LATENCY_DISTRIBUTION>    Comma separated latency values. E.g. 200,200,200,500
    -N, --name <NAME>                       Name of the test-case
    -n, --num_req <NUM_REQUESTS>            Number of requests. E.g. 1000
    -p, --python_path <PYTHON_PATH>         Optional path to python3, e.g. /usr/bin/python3
    -r, --rate <RATE>                       Request rate per second. E.g. 100 or 1000
SUBCOMMANDS:
    async    Model a service with Async I/O
    help     Prints this message or the help of the given subcommand(s)
    sync     Model a service with Blocking I/O
输出示例
Latencies:
p0.000 - 0.477 ms
p50.000 - 0.968 ms
p90.000 - 1.115 ms
p95.000 - 1.169 ms
p99.000 - 1.237 ms
p99.900 - 1.295 ms
p99.990 - 1.432 ms
p100.000 - 1.469 ms
Avg rate: 1000.000, StdDev: 0.000
运行同步示例
- 1000 RPS
- 20毫秒延迟,10个端点
- 500个线程
concurrency-demo-benchmarks --name sync_t500_20ms \
                            --rate 1000 \
                            --num_req 10000 \
                            --latency "20ms*10" \
                            sync --threads 500
- 1000 RPS
- 针对10个目标,60毫秒延迟
- 500个线程
concurrency-demo-benchmarks --name sync_t500_60ms \
                            --rate 1000 \
                            --num_req 10000 \
                            --latency "60ms*10" \
                            sync --threads 500
- 1000 RPS
- 针对9个目标,20毫秒延迟,但另一个为30秒
- 500个线程
concurrency-demo-benchmarks --name sync_t500_30s \
                            --rate 1000 \
                            --num_req 100000 \
                            --latency "20ms*9,30s" \
                            sync --threads 500
运行异步演示
- 1000 RPS
- 20毫秒延迟,10个目标
concurrency-demo-benchmarks --name async_20ms \
                            --rate 1000 \
                            --num_req 10000 \
                            --latency "20ms*10" \
                            async
- 1000 RPS
- 60毫秒延迟,10个目标
concurrency-demo-benchmarks --name async_60ms \
                            --rate 1000 \
                            --num_req 100000 \
                            --latency "60ms*10" \
                            async
- 1000 RPS
- 20毫秒延迟,但10%为30秒
concurrency-demo-benchmarks --name async_30s \
                            --rate 1000 \
                            --num_req 100000 \
                            --latency "20ms*9,30s" \
                            async
依赖关系
~19–29MB
~258K SLoC