Giter VIP home page Giter VIP logo

bench-of-chan's Introduction

问题

给 N 个 worker 投递 M 个 event,这 N 个 worker 的处理逻辑运行在不同的用户态线程中,以此来测试队列(chan或是channel)以及协程调度的性能。

说明

worker 通过一个 event 输入队列来得到输入事件,它从该队列中重复的读取事件,直到收到结束事件,每收到一个事件,累加一个全局的原子(atmoic)计数器,当该计数器到达 M * N 时,通知所有任务完成。

事件为指定大小的字节数组。

  • go 自带 goroutinechan,所以每个 worker 运行在自己的 goroutine 中,队列则使用 chan
  • rust 使用 tokio 作为调度运行时,每个 worker 是一个由 tokio::spawn 产生的异步任务,队列使用 tokio::sync::mpsc::channel

结果

结果是每秒的消息投递数目,详细的如下表所示

worker event rust go diff (go/rust)
100 100 17,568,517 7,186,489 40.91%
100 500 30,231,574 21,794,089 72.09%
100 1000 30,697,446 12,443,383 40.54%
100 2000 33,844,956 16,100,597 47.57%
100 5000 33,456,229 15,676,242 46.86%
1000 100 30,809,995 22,544,356 73.17%
1000 500 34,041,163 25,164,830 73.92%
1000 1000 31,695,118 23,580,345 74.40%
1000 2000 35,061,147 23,615,985 67.36%
1000 5000 35,093,482 24,367,149 69.43%

bench-of-chan's People

Contributors

elsejj avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.