Skip to content

Commit 619f10e

Browse files
HasenpfoteHasenpfote
authored andcommitted
Change some descriptions
1 parent c03ae8b commit 619f10e

File tree

2 files changed

+120
-0
lines changed

2 files changed

+120
-0
lines changed

README.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,66 @@ malloc_tracer
88
## About
99
This is a debugging tool for tracing malloc that occurs inside a function or class.
1010

11+
```python
12+
import numpy as np
13+
from malloc_tracer.tracer import *
14+
15+
16+
def func(x, y, z):
17+
dataset1 = np.empty((100, ), dtype=np.float64)
18+
print('x', x)
19+
dataset1 = np.empty((1000, ), dtype=np.float64)
20+
21+
l = [i for i in range(100000)]
22+
23+
if x == 0:
24+
dataset4a = np.empty((100000, ), dtype=np.float64)
25+
return 0
26+
elif x == 1:
27+
dataset4b = np.empty((100000, ), dtype=np.float64)
28+
return 1
29+
30+
dataset3 = np.empty((3000, ), dtype=np.float64)
31+
return 2
32+
33+
34+
tracer = Tracer(func)
35+
```
36+
37+
This is equivalent to the following code.
38+
39+
```python
40+
import numpy as np
41+
from tracemalloc import start, take_snapshot, stop
42+
43+
44+
SNAPSHOT = None
45+
46+
47+
def func(x, y, z):
48+
try:
49+
start()
50+
dataset1 = np.empty((100,), dtype=np.float64)
51+
print('x', x)
52+
dataset1 = np.empty((1000,), dtype=np.float64)
53+
54+
l = [i for i in range(100000)]
55+
56+
if (x == 0):
57+
dataset4a = np.empty((100000,), dtype=np.float64)
58+
return 0
59+
elif (x == 1):
60+
dataset4b = np.empty((100000,), dtype=np.float64)
61+
return 1
62+
63+
dataset3 = np.empty((3000,), dtype=np.float64)
64+
return 2
65+
finally:
66+
global SNAPSHOT
67+
SNAPSHOT = take_snapshot()
68+
stop()
69+
```
70+
1171
## Feature
1272

1373
## Compatibility

README.rst

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,66 @@ About
1111
This is a debugging tool for tracing malloc that occurs inside a
1212
function or class.
1313

14+
.. code:: python
15+
16+
import numpy as np
17+
from malloc_tracer.tracer import *
18+
19+
20+
def func(x, y, z):
21+
dataset1 = np.empty((100, ), dtype=np.float64)
22+
print('x', x)
23+
dataset1 = np.empty((1000, ), dtype=np.float64)
24+
25+
l = [i for i in range(100000)]
26+
27+
if x == 0:
28+
dataset4a = np.empty((100000, ), dtype=np.float64)
29+
return 0
30+
elif x == 1:
31+
dataset4b = np.empty((100000, ), dtype=np.float64)
32+
return 1
33+
34+
dataset3 = np.empty((3000, ), dtype=np.float64)
35+
return 2
36+
37+
38+
tracer = Tracer(func)
39+
40+
This is equivalent to the following code.
41+
42+
.. code:: python
43+
44+
import numpy as np
45+
from tracemalloc import start, take_snapshot, stop
46+
47+
48+
SNAPSHOT = None
49+
50+
51+
def func(x, y, z):
52+
try:
53+
start()
54+
dataset1 = np.empty((100,), dtype=np.float64)
55+
print('x', x)
56+
dataset1 = np.empty((1000,), dtype=np.float64)
57+
58+
l = [i for i in range(100000)]
59+
60+
if (x == 0):
61+
dataset4a = np.empty((100000,), dtype=np.float64)
62+
return 0
63+
elif (x == 1):
64+
dataset4b = np.empty((100000,), dtype=np.float64)
65+
return 1
66+
67+
dataset3 = np.empty((3000,), dtype=np.float64)
68+
return 2
69+
finally:
70+
global SNAPSHOT
71+
SNAPSHOT = take_snapshot()
72+
stop()
73+
1474
Feature
1575
-------
1676

0 commit comments

Comments
 (0)