def test_splitter_perf(self):
    test_file = self.get_test_loc('perf/test.txt')
    text = (open(test_file).read() * 100)
    utext = unicode(text)
    setup1 = ("\nimport re\nfrom textcode import analysis\n\nunicode_ws = analysis.word_splitter\nplain_ws =re.compile(r'[^\\W_]+').finditer\nunicode_ts = analysis.template_splitter\nplain_ts= re.compile(r'(?:[^\\W_])+|(?:\\{\\{)|(?:\\}\\})').finditer\n\ntext = %r\nutext = %r" % (text, utext))

    def check_perf(setup):
        from timeit import timeit
        stmt = 'list(w for w in %s(%s))'
        print()
        print('Unicode template')
        print(timeit((stmt % ('unicode_ts', 'utext')), setup=setup, number=1000))
        print('Plain template')
        print(timeit((stmt % ('plain_ts', 'text')), setup=setup, number=1000))
        print('Unicode words')
        print(timeit((stmt % ('unicode_ws', 'utext')), setup=setup, number=1000))
        print('Plain words')
        print(timeit((stmt % ('plain_ws', 'text')), setup=setup, number=1000))
        print('Plain split')
        print(timeit('text.split()', setup=setup, number=1000))
        print('Unicode split')
        print(timeit('utext.split()', setup=setup, number=1000))
        print('Line split')
        print(timeit('text.splitlines(False)', setup=setup, number=1000))
        print('Line split with ends')
        print(timeit('text.splitlines(True)', setup=setup, number=1000))
    check_perf(setup=setup1)
    setup2 = ("\nimport re\nfrom textcode import analysis\n\nunicode_ws = analysis.word_splitter\nplain_ws =re.compile(r'[^\\W_]+').finditer\nunicode_ts = analysis.template_splitter\nplain_ts= re.compile(r'(?:[^\\W_])+|(?:\\{\\{)|(?:\\}\\})').finditer\n\ntext = %r\nutext = %r" % (text, utext))
    check_perf(setup=setup2)
def test_splitter_perf(self):
    test_file = self.get_test_loc('perf/test.txt')
    text = (open(test_file).read() * 100)
    utext = unicode(text)
    setup1 = ("\nimport re\nfrom textcode import analysis\n\nunicode_ws = analysis.word_splitter\nplain_ws =re.compile(r'[^\\W_]+').finditer\nunicode_ts = analysis.template_splitter\nplain_ts= re.compile(r'(?:[^\\W_])+|(?:\\{\\{)|(?:\\}\\})').finditer\n\ntext = %r\nutext = %r" % (text, utext))

    def check_perf(setup):
        from timeit import timeit
        stmt = 'list(w for w in %s(%s))'
        print()
        print('Unicode template')
        print(timeit((stmt % ('unicode_ts', 'utext')), setup=setup, number=1000))
        print('Plain template')
        print(timeit((stmt % ('plain_ts', 'text')), setup=setup, number=1000))
        print('Unicode words')
        print(timeit((stmt % ('unicode_ws', 'utext')), setup=setup, number=1000))
        print('Plain words')
        print(timeit((stmt % ('plain_ws', 'text')), setup=setup, number=1000))
        print('Plain split')
        print(timeit('text.split()', setup=setup, number=1000))
        print('Unicode split')
        print(timeit('utext.split()', setup=setup, number=1000))
        print('Line split')
        print(timeit('text.splitlines(False)', setup=setup, number=1000))
        print('Line split with ends')
        print(timeit('text.splitlines(True)', setup=setup, number=1000))
    check_perf(setup=setup1)
    setup2 = ("\nimport re\nfrom textcode import analysis\n\nunicode_ws = analysis.word_splitter\nplain_ws =re.compile(r'[^\\W_]+').finditer\nunicode_ts = analysis.template_splitter\nplain_ts= re.compile(r'(?:[^\\W_])+|(?:\\{\\{)|(?:\\}\\})').finditer\n\ntext = %r\nutext = %r" % (text, utext))
    check_perf(setup=setup2)