File: test-memory.py

package info (click to toggle)
scalene 1.5.54-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 15,980 kB
  • sloc: cpp: 22,870; python: 14,493; javascript: 12,297; ansic: 817; makefile: 196; sh: 45
file content (36 lines) | stat: -rwxr-xr-x 689 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
36
#!/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()