Test computer processing speed with a simple Python script

I want to make a simple script just to test the time that the computer takes to execute it. I already built it with PyQt and made a kinda loop using QTimer. Now i need the "make busy" part. What kind of commands can I use just to make the computer work a little so I can get the time it takes and compare with other computers?

Here is my code so you can understand better:

self.Tempo = QtCore.QTimer(None)
self.Cron = QtCore.QTime(0,0,0,0)

def begin():
    self.Cron.start()
    self.Tempo.singleShot(999, update)       
def update():
    if self.lcdNumber.value() == 10:
        finish()                
    else:
        self.lcdNumber.display(self.lcdNumber.value()+1)
        #Here I want to make some processing stuff            
        self.Tempo.singleShot(999, update)
def finish():
    print("end")
    took = self.Cron.elapsed() / 1000
    print("took: {0} seconds" .format(str(took)))
    self.lcdNumber_2.display(took)

Answers


You can do any complex calculation problem in a loop:

  • Calculate factorial for some big number (easy to implement)
  • Calculate chain SHA1 hash 100 000 times (very easy to implement)
  • Invert big matrix (no so easy to implement)
  • ...
  • etc.

Some of those problems use CPU (factorial, SHA1), some others - CPU and memory (matrix invert). So first you need to decide, which part of computer you want to benchmark.


Need Your Help

JQuery dialog box not appearing in current screen center

php jquery html jquery-ui

I have a test php file which has 50 buttons in a table (just to make a big table). When the first button is clicked, I want a JQuery dialog box which has a html textbox to open via JQuery. For now,...

How to handle deeply nested exception in struts2?

exception-handling struts2

My struts2 webapp makes use of a SQL database. Within the DB access code, I've written a basic try/catch handler that catches SQL or general exceptions, writes the detail to a log file, and then

Java JTextArea Question

java jtextarea

I am designing an on-screen form to be filled in, and I think it makes sense to stick it together as a collection of text areas. I note in the documentation of JTextArea that a text area can be