Skip to content
This repository has been archived by the owner on Nov 23, 2019. It is now read-only.

Python3 vs python2 performance #22

Closed
fuzzycow opened this issue Sep 6, 2014 · 1 comment
Closed

Python3 vs python2 performance #22

fuzzycow opened this issue Sep 6, 2014 · 1 comment

Comments

@fuzzycow
Copy link

fuzzycow commented Sep 6, 2014

Using the following snippet - it looks like simple "with open / read" combo on ev3 python3 is about twice as slow as python2
Using "rb" flag to open lowers the gap significantly, but doesn't eliminate it completely.

Since ev3dev / python-ev3 requires quite a bit of file open/read operations - perhaps a note should be made on project page about this?

mini-benchmark results:
python2 - ~617
python3 - ~280
python3 with open(filename,"rb") - ~480

filename = "/sys/class/power_supply/legoev3-battery/voltage_now"
status_every = 1000
counter = 1
t = time.clock()
while True:
    for _ in range(1,2):
        with open(filename,"rb") as f:
            data = f.read()
    counter += 1
    if ( counter % status_every ) == 0:
        tps = status_every / (time.clock() - t )
        print("tps : %f" % tps )
        t = time.clock()

P.S.: Many thanks for your work on python-ev3 ! :)

@topikachu
Copy link
Owner

I will document your finding. Thanks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants