Sunday, July 22, 2012

More Raspberry Pi Printing Tests

Here is some evidence to see if the scroll is the limiting factor for the Raspberry Pi on a local session.

(For more precise machine specifications, see previous blog post)

Some Basic Analysis of the Results

All the results are much faster without a newline per number.

In the case of HDMI Screen ‘for_print_comma” - I’m not sure why it takes 8ms to print 30 numbers since three times that number fit onto a single line. This seems to suggest an effect that is not the scroll speed.

It’s also interesting that both the SSHed results are faster - I’m guessing that the newline is causing an expensive flush (and maybe a new packet) each time. The ‘for_print_comma’ speeds are now of the same order.

The local Terminal result on the Core i7 is also faster - which would be related to the newline flush and the scroll speed not being CPU independent.

I also still don’t understand why the ‘for_print’ on the Raspberry Pi is so much slower than the Dreamplug. They are both ‘similar’ processors, running Debian Linux (albeit two major versions apart).

Perhaps the slow response of the HDMI screen and the SSH to newlines is related?

Results

Raspberry Pi - HDMI Screen

for_print = 70279.1 microseconds/function ( total = 70.2761 s)
for_print_comma = 8067.89 microseconds/function ( total = 8.06789 s)

Raspberry Pi - SSH

for_print = 12303.9 microseconds/function ( total = 12.3039 s)
for_print_comma = 605.202 microseconds/function ( total = 0.605202 s)

Dreamplug - SSH

for_print = 857.302 microseconds/function ( total = 0.857302 s)
for_print_comma = 365.109 microseconds/function ( total = 0.365109 s)

Core i7 - Terminal

for_print = 161.338 microseconds/function ( total = 0.161338 s)
for_print_comma = 16.202 microseconds/function ( total = 0.016202 s)

Source Code


# Various really stupid Python benchmarking tests
# Rob Probin 2012

import time
import math

def for_print():
    for i in xrange(30):
        print i

def for_print_comma():
    for i in xrange(30):
        print i,
       
test_suite = [
    ("for_print", 1000),
    ("for_print_comma", 1000),
]

if __name__ == '__main__':   
    result = []
    from timeit import Timer
   
    for test in test_suite:
        test_name, passes = test
       
        print("RUNNING TEST:", test_name)
        t = Timer(test_name+"()", "from __main__ import "+test_name)
        test_time = t.timeit(number=passes)
        test_results = (test_name, test_time, test_time/passes)
        result.append(test_results)

    print
    for result_set in result:
        (name, total, func_time) = result_set
        print "%s = %g microseconds/function ( total = %g s)" % (name, func_time*1000000, total)

0 Comments:

Post a Comment

<< Home

Newer›  ‹Older