File: test-memory.py

package info (click to toggle)
scalene 1.5.51-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 15,528 kB
  • sloc: cpp: 22,930; python: 13,403; javascript: 11,769; ansic: 817; makefile: 196; sh: 45
file content (35 lines) | stat: -rwxr-xr-x 675 bytes parent folder | download
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
#!/usr/bin/env python3
import numpy as np
import sys

x = np.ones((1,1))
print(sys.getsizeof(x) / 1048576)

x = np.ones((1000,1000))
print(sys.getsizeof(x) / 1048576)

x = np.ones((1000,2000))
print(sys.getsizeof(x) / 1048576)

x = np.ones((1000,20000))
print(sys.getsizeof(x) / 1048576)

# @profile
def allocate():
    for i in range(100):
        x = np.ones((1000,1000))
        x = np.ones((1,1))
        x = np.ones((1,1))
        x = np.ones((1,1))
        x = np.ones((1000,2000))
        x = np.ones((1,1))
        x = np.ones((1,1))
        x = np.ones((1,1))
        x = np.ones((1000,20000))
        x = 1
        x += 1
        x += 1
        x += 1

allocate()