import time
import os

# Find all .xsl/.xml pairs
testcase_directory = r'C:\Dev\Me\Pyana\xsltmark\testcases'
testcase_files = os.listdir(testcase_directory)
testcase_files.sort()

last_name = None
tests = []
for file in testcase_files:
    name, ext = os.path.splitext(file)
    if ext == '.xsl':
        if last_name == name:
            tests.append(name)
        last_name = None
    elif ext == '.xml':
        last_name = name
    else:
        last_name = None


print 'time to import Pyana:',
startTime = time.clock()
import Pyana
print "%0.4fs" % (time.clock() - startTime)

for test in tests:
    print 'time to execute %s:' % test,
    startTime = time.clock()
    length = len(Pyana.transformToString(source = Pyana.URI(os.path.join(testcase_directory, test + '.xml')),
                            style = Pyana.URI(os.path.join(testcase_directory, test + '.xsl'))))
    print "%0.4fs (%d bytes of output)" % (time.clock() - startTime, length) 