Credit to socrates . to https://github.com/celomary for some python explanations
A small testing framework for 42's philosophers.
New: now includes Delay-o-meter, a tool to measure sleep inaccuracy
Big thanks to:
solaldunckel for helping to test this project!
cacharle for their awesome pull requests that are pushing this project forward!
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!
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
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!
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.
Requirements: python 3.6+, psutil
- Clone the repo
git clone https://github.com/nesvoboda/socrates
cd socrates
- 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!
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.
python3 socrates.py <path to project folder>