[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [pygame] Debug printouts - faster to screen or file?
ok, ok, to get past our "theoretical" discussion, i wrote a quick and
simple test. i'm sure results will vary wildly for different platforms,
but i think we'll see the printing to file is by far the leader..
for a pentium2-300 on winnt 4, i get this:
PERFORMANCE RESULTS
stdout 3.42 seconds
file 0.05 seconds
cheers to modern filesystems and efficient caching :]
i guess i should note this was run in a console window with about 80x40
characters.
"""test the output speed to various devices"""
import sys, time
def printingtime():
start = time.time()
for i in xrange(1000):
print 'Sometimes we must debug, but where should it go?'
print '\tThe value of "i" i equal to the value:', i
end = time.time()
return end - start
orig_stdout = sys.stdout
time_stdout = printingtime()
sys.stdout = open('debug_stdout.txt', 'w')
time_file = printingtime()
sys.stdout = orig_stdout
print "\nPERFORMANCE RESULTS"
print "stdout %.2f seconds" % time_stdout
print "file %.2f seconds" % time_file