Giter Club home page Giter Club logo

threadtest's Introduction

ThreadTest

Here we have 2000 BotSimulators running concurrently, each on its own thread. They have some simulated contention on a couple shared resources in the form of a counter and printing. The amount of work they do before contention is configurable as kWorkCycles. Between contention times, bot's sleep a random amount of time on a configurable interval (kMinSleepTimeUSec,kMaxSleepTimeUSec) to simulate a lack of packet data coming from the server.

My results

1

If we take a conservative approach and assume that packets will never come any sooner than 100us(kMinSleepTimeUSec=100) apart or any longer than 1ms(kMaxSleepTimeUSec=1000) apart. Also, we'll assume there's a lot of data to be crunched before contention, so we'll set kWorkCycles=10000.

My CPU spikes and things get laggy, but the after 10 seconds, the console reports that the completed number of units of work was 7,030,003 meaning collaboratively between all 2000 bots, 703,000 units of work were done per second.

2

If we instead do kWorkCycles=100, after 10 seconds, we get 31,390,005.

img

Build

Build in linux with g++ -o sim sim.cpp -std=c++14 -pthread -O3

threadtest's People

Contributors

sandsnip3r 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.