File: test_nested.py

package info (click to toggle)
python-memory-profiler 0.41%2Bgit20161018-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 280 kB
  • ctags: 163
  • sloc: python: 1,469; makefile: 24
file content (29 lines) | stat: -rw-r--r-- 427 bytes parent folder | download | duplicates (5)
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
# .. an example with a for loop ..

import time

@profile
def test_1():
    a = [1] * (10 ** 6)
    b = [2] * (2 * 10 ** 7)
    del b

    def test_2():
        a = [1] * (10 ** 6)
        b = [2] * (2 * 10 ** 7)
        del b

        return a

    return test_2


if __name__ == '__main__':
    profile.enable_by_count()

    test_2 = test_1()
    time.sleep(1)
    test_2()
    time.sleep(1)

    profile.disable_by_count()