User Tools

Site Tools


files:python3:output_tests

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
files:python3:output_tests [2018/08/15 16:29]
kericson created, added first 2 files
files:python3:output_tests [2018/08/15 16:38] (current)
kericson Added comment about timeit and link to it
Line 1: Line 1:
 +Tests make use of [[https://docs.python.org/3/library/timeit.html|timeit]] to ensure we are only measuring ''print()'' and ''write()''. ((//Not// the overhead of loading data into memory))
 +
 <file python print.py> <file python print.py>
 import timeit import timeit
Line 39: Line 41:
 print(timeit.timeit("myFun(lines)",number=5,setup=setup), file=sys.stderr) print(timeit.timeit("myFun(lines)",number=5,setup=setup), file=sys.stderr)
 </file> </file>
 +
 +
 +<file python read_test.py>
 +from sys import argv
 +from random import *
 +from string import *
 +
 +for i in range(int(argv[1])):
 +    print(''.join(choice(ascii_lowercase + ' ') for _ in range(int(argv[2]))))
 +</file>
 +
 +
 +((''python3 read_test.py lines length > out.txt'', where ''lines'' is the number of lines and ''length'' is the number of characters per line.))
 +
files/python3/output_tests.1534368594.txt.gz ยท Last modified: 2018/08/15 16:29 by kericson