File: test_memory_nomemoization.py

package info (click to toggle)
arpeggio 2.0.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,480 kB
  • sloc: python: 3,198; javascript: 54; sh: 19; makefile: 9
file content (36 lines) | stat: -rw-r--r-- 1,194 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#-*- coding: utf-8 -*-
#######################################################################
# Purpose: Testing memory consumption with memoization disabled
# Author: Igor R. Dejanovic <igor DOT dejanovic AT gmail DOT com>
# Copyright: (c) 2016 Igor R. Dejanovic <igor DOT dejanovic AT gmail DOT com>
# License: MIT License
#######################################################################
from __future__ import print_function, unicode_literals

import codecs
from os.path import dirname, join
from memory_profiler import profile
from arpeggio import ParserPython
from grammar import rhapsody

@profile
def no_memoization():

    parser = ParserPython(rhapsody, memoization=False)

    # Smaller file
    file_name = join(dirname(__file__), 'test_inputs', 'LightSwitch.rpy')
    with codecs.open(file_name, "r", encoding="utf-8") as f:
        content = f.read()

    small = parser.parse(content)

    # File that is double in size
    file_name = join(dirname(__file__), 'test_inputs', 'LightSwitchDouble.rpy')
    with codecs.open(file_name, "r", encoding="utf-8") as f:
        content = f.read()

    large = parser.parse(content)

if __name__ == '__main__':
    no_memoization()