0

I have written a script to compare a few algorithms in Python, and I am timing each algorithm, to compare the total running time of each one. I wish to be as accurate as possible, that is, I want all of the algorithms to be ran using exactly (as much as possible) the same resources.

Running the script in GUI, I face the problem that Linux is checking for updates, running background processes e.t.c. So my concern is, that while running algorithm 1, linux is checking for updates, so it's not a fair comparison.

Any ideas on how I can control that? I am running Kubuntu.

XuUserAC
  • 101
  • 1
    The simplest thing you can try is to jump into lower runlevel - probably into multi-user mode. Depends on how far you want to take it. :D Many fanciness is tied to graphical.target runlevel so getting rid of that could provide you with system usable for benchmarks. You will have only a shell access, but you can run the tests, dump the result, then go back to graphical and evaluate them then. – Fiisch Jul 15 '20 at 10:30
  • 1
    To make any such bench-marking meaningful you must execute it many times because there are too many variables outside your control. If you've not done so already then take a look at python's timeit package. This will let you run an algorithm many times over and time the total. – Philip Couling Jul 15 '20 at 14:00
  • You can always play with process priority levels, but if you try that make sure you understand what you're doing as bad usage could run with worse results than default. The answers of this question are pretty detailed. – l3l_aze Jul 16 '20 at 01:09

0 Answers0