Object instantiation time benchmark in Python : ARM vs. x86

Wojciech Ziniewicz
Stories imported from wordpress
1 min readMay 27, 2013

Suppose we have two machines.

  • Intel x86 : Core Duo 1.86GHz CPU — python 2.7.4 on Ubuntu 13.04
  • RaspberryPi — ARM 700Mhz CPU -python 2.7.3 on raspbianOS

Here we have supersimple benchmark object with few attributes.

[code language=”python”]
c=0
for i in range(0,1000000):
a = time.time()
i = BenchmarkCommand(1,2,3)
b = time.time()
c = c + (b — a)
[/code]

And now the BenchmarkCommand class that is used for instantiation:

[code language=”python”]
class BenchmarkCommand:
def __init__(self, val, parent, command_instance):
self.val = val
self.parent = parent
self.exit_code = 127
self.executed = 0
self.command = command_instance
‘’’ Adding and removing timestamp changes a lot ‘’’
self.timestamp = time.time()
def execute(self):
try:
self.command()
self.exit_code = 0
except Exception, message:
print “There was a problem with execution of value %s on node %s because of %s” % (str(val), str(parent), message)
finally:
self.executed = 1
[/code]

So what do we get:

  • ARM : 44.51s elapsed time with “time.time()” attribute and 30.49s without that attribute
  • x86: 4.15s elapsed time with “time.time()” attribute and 2.80s without that

--

--