Commit 8f2ef644 authored by Igor Dejanovic's avatar Igor Dejanovic

Separating unit and speed tests

parent 2c9dbbc3
import pstats
p = pstats.Stats('calc.profile')
p.strip_dirs().sort_stats('cumulative').print_stats()
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)*-45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)*-45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)*-45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)*-45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)*-45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)*-45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)*-45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)*-45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)*-45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)*-45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)*-45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)*-45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)*-45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)*-45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)*-45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)*-45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)*-45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)*-45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)*-45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)*-45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)*-45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)*-45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)*-45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)*-45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)*-45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)*-45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)*-45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)*-45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)*-45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)*-45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)*-45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)*-45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)*-45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)*-45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)*-45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)*-45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)*-45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)*-45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)*-45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)*-45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)*-45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)*-45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)*-45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)*-45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)*-45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)*-45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)*-45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)*-45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)*-45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)*-45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)*-45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)*-45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)*-45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)*-45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
45-4*(23+7.45-67*32.3)/67*45.56-129.67*(343-56+33.4/45)
# -*- coding: utf-8 -*-
#######################################################################
# Name: test_speed
# Purpose: Performance test of arpeggio parser
# Author: Igor R. Dejanović <igor DOT dejanovic AT gmail DOT com>
# Copyright: (c) 2014 Igor R. Dejanović <igor DOT dejanovic AT gmail DOT com>
# License: MIT License
#######################################################################
import timeit, sys
if __name__ == "__main__":
setup = '''
from arpeggio import OneOrMore, ZeroOrMore, EndOfFile, ParserPython, Optional
from arpeggio import RegExMatch as _
def number(): return _(r'\d*\.\d*|\d+')
def factor(): return [(Optional(["+","-"]), number), ("(", expression, ")")]
def term(): return factor, ZeroOrMore(["*","/"], factor)
def expression(): return term, ZeroOrMore(["+", "-"], term)
def calcfile(): return OneOrMore(expression), EndOfFile
parser = ParserPython(calcfile, reduce_tree=True)
with open("input.txt", "r") as f:
input = f.read()
'''
print(timeit.timeit("parser.parse(input)", setup=setup, number=20))
# 7.06 s
import pstats
p = pstats.Stats('test_speed.profile')
p.strip_dirs().sort_stats('cumulative').print_stats()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment