Code Monkey home page Code Monkey logo

philosophers-tester's Introduction

philosophers tester 42

Credit to socrates . to https://github.com/celomary for some python explanations Logo

socrates

Code style: black Run tests codecov

A small testing framework for 42's philosophers.

New: now includes Delay-o-meter, a tool to measure sleep inaccuracy

Acknowledgements

Big thanks to:

solaldunckel for helping to test this project!

cacharle for their awesome pull requests that are pushing this project forward!

What are the tests?

Socrates tests two things.

In PERFORMANCE tests, it times how long your program runs in a test case where no philosophers should die (like 550 210 210). By default, your program should hold on for 40 seconds.

In a DEATH TIMING test, we make a philosopher die (sorry!) (example: 100 500 500, a philosopher will die at 100ms). The output of your program is then parsed to measure how soon your program reported that.

If your delay is more than 10ms, the test is failed!

A screenshot showing a typical test output

Delay-o-meter

Different machines perform sleeps with different accuracy. Socrates reports the average delay the machine will add to a 200-millisecond sleep. This can help make sure other stuff running on the computer doesn't interfere with Philosopher timings.

You can also use a standalone tool and check different machines:

python3 delay_o_meter.py

How to interpret the result?

The common-sense standard of a good Philosophers is less than 10ms of delay per one eat-sleep-think cycle (example: 310 150 150 should run forever).

My personal opinion is that, therefore, a machine must lose less than 3ms on average for tests to be accurate. Let me know what you think about that!

CPU load detector

Another way of making sure nothing prevents your philosophers from working properly, Socrates checks the load of your CPU. If it's overloaded, it will show a message.

Here's an article that explains why this is important, especially on a VM.

A screenshot showing the test output with a message: CPU OVERLOADED! RESULTS MAY BE WRONG

Installation

Requirements: python 3.6+, psutil

  1. Clone the repo
git clone https://github.com/nesvoboda/socrates
cd socrates
  1. Install the prerequisites
pip3 install -r requirements.txt

If you're in a 42 campus, run this instead:

python3 -m pip install -r requirements.txt --user

If installation fails on Linux, try this:

sudo apt-get install python3.7-dev

Thanks to Mazoise for this suggestion!

Configuration

You can edit the variables N_LONG_TESTS and LONG_TEST_LENGTH to determine how long the preformance tests will last. My standard is 3 consecutive runs of at least 40 seconds.

Running the tests

python3 socrates.py <path to project folder>

philosophers-tester's People

Contributors

goat095 avatar

Stargazers

Assia avatar HADARI YACINE avatar  avatar Amine TAHIRI [KapitCha] avatar Pedro avatar teslazap avatar Khalid Eddib avatar  avatar Zakaria Taouil avatar Aissam El Khaloufi avatar Oussama Joubouti avatar Younes Arroubi avatar CMOS avatar Mohammed Amine Ajdahim avatar Ael-mezz avatar Abdelaziz avatar Achraf El fadili avatar

Watchers

James Cloos avatar  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.