Skip to content

Commit ffc3a8e

Browse files
HasenpfoteHasenpfote
authored andcommitted
Change some descriptions
1 parent b2ce75f commit ffc3a8e

File tree

2 files changed

+45
-26
lines changed

2 files changed

+45
-26
lines changed

README.md

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ This is a debugging tool for tracing malloc that occurs inside a function or cla
1111

1212
```python
1313
import numpy as np
14-
from malloc_tracer.tracer import *
14+
import malloc_tracer
1515

1616

1717
def func(x, y, z):
@@ -32,7 +32,7 @@ def func(x, y, z):
3232
return 2
3333

3434

35-
tracer = Tracer(func)
35+
tracer = malloc_tracer.Tracer(func)
3636
```
3737

3838
This is equivalent to the following code.
@@ -85,7 +85,7 @@ pip install malloc-tracer
8585
**Trace a function.**
8686
```python
8787
import numpy as np
88-
from malloc_tracer.tracer import *
88+
import malloc_tracer
8989

9090

9191
def func(x, y, z):
@@ -107,7 +107,7 @@ def func(x, y, z):
107107
```
108108

109109
```python
110-
tracer = Tracer(func)
110+
tracer = malloc_tracer.Tracer(func)
111111
tracer.trace(
112112
target_args=dict(x=1, y=2, z=3)
113113
)
@@ -117,7 +117,7 @@ tracer.trace(
117117
**Trace a method.**
118118
```python
119119
import numpy as np
120-
from malloc_tracer.tracer import *
120+
import malloc_tracer
121121

122122

123123
class Klass(object):
@@ -158,7 +158,7 @@ class Klass(object):
158158

159159
```python
160160
instance = Klass(1)
161-
tracer = Tracer(instance.method)
161+
tracer = malloc_tracer.Tracer(instance.method)
162162
tracer.trace(
163163
target_args=dict(x=1)
164164
)
@@ -167,7 +167,7 @@ tracer.trace(
167167

168168
**Trace a static method.**
169169
```python
170-
tracer = Tracer(Klass.smethod)
170+
tracer = malloc_tracer.Tracer(Klass.smethod)
171171
tracer.trace(
172172
target_args=dict()
173173
)
@@ -176,7 +176,7 @@ tracer.trace(
176176

177177
**Trace a class method.**
178178
```python
179-
tracer = Tracer(Klass.cmethod)
179+
tracer = malloc_tracer.Tracer(Klass.cmethod)
180180
tracer.trace(
181181
target_args=dict(var='Hello world.')
182182
)
@@ -186,7 +186,7 @@ tracer.trace(
186186
**Displays related traces for each file.**
187187
```python
188188
import numpy as np
189-
from malloc_tracer.tracer import *
189+
import malloc_tracer
190190

191191

192192
global_var1 = None
@@ -221,23 +221,32 @@ def func(x, y, z):
221221
```
222222

223223
```python
224-
tracer = Tracer(func)
224+
tracer = malloc_tracer.Tracer(func)
225225
tracer.trace(
226226
target_args=dict(x=1, y=2, z=3),
227-
related_traces_output_mode=RelatedTracesOutputMode.FOR_EACH_FILE
227+
related_traces_output_mode=malloc_tracer.RelatedTracesOutputMode.FOR_EACH_FILE
228228
)
229229
```
230230
![usage3a](https://raw.githubusercontent.com/Hasenpfote/malloc_tracer/master/docs/usage3a.png)
231231

232232
**Displays related traces in descending order.**
233233
```python
234-
tracer = Tracer(func)
234+
tracer = malloc_tracer.Tracer(func)
235235
tracer.trace(
236236
target_args=dict(x=1, y=2, z=3),
237-
related_traces_output_mode=RelatedTracesOutputMode.IN_DESCENDING_ORDER
237+
related_traces_output_mode=malloc_tracer.RelatedTracesOutputMode.IN_DESCENDING_ORDER
238238
)
239239
```
240240
![usage3b](https://raw.githubusercontent.com/Hasenpfote/malloc_tracer/master/docs/usage3b.png)
241241

242+
**Convenience function.**
243+
```python
244+
malloc_tracer.trace(
245+
func,
246+
target_args=dict(x=1, y=2, z=3),
247+
related_traces_output_mode=malloc_tracer.RelatedTracesOutputMode.IN_DESCENDING_ORDER
248+
)
249+
```
250+
242251
## License
243252
This software is released under the MIT License, see LICENSE.

README.rst

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function or class.
1515
.. code:: python
1616
1717
import numpy as np
18-
from malloc_tracer.tracer import *
18+
import malloc_tracer
1919
2020
2121
def func(x, y, z):
@@ -36,7 +36,7 @@ function or class.
3636
return 2
3737
3838
39-
tracer = Tracer(func)
39+
tracer = malloc_tracer.Tracer(func)
4040
4141
This is equivalent to the following code.
4242

@@ -98,7 +98,7 @@ Usage
9898
.. code:: python
9999
100100
import numpy as np
101-
from malloc_tracer.tracer import *
101+
import malloc_tracer
102102
103103
104104
def func(x, y, z):
@@ -120,7 +120,7 @@ Usage
120120
121121
.. code:: python
122122
123-
tracer = Tracer(func)
123+
tracer = malloc_tracer.Tracer(func)
124124
tracer.trace(
125125
target_args=dict(x=1, y=2, z=3)
126126
)
@@ -135,7 +135,7 @@ Usage
135135
.. code:: python
136136
137137
import numpy as np
138-
from malloc_tracer.tracer import *
138+
import malloc_tracer
139139
140140
141141
class Klass(object):
@@ -176,7 +176,7 @@ Usage
176176
.. code:: python
177177
178178
instance = Klass(1)
179-
tracer = Tracer(instance.method)
179+
tracer = malloc_tracer.Tracer(instance.method)
180180
tracer.trace(
181181
target_args=dict(x=1)
182182
)
@@ -190,7 +190,7 @@ Usage
190190

191191
.. code:: python
192192
193-
tracer = Tracer(Klass.smethod)
193+
tracer = malloc_tracer.Tracer(Klass.smethod)
194194
tracer.trace(
195195
target_args=dict()
196196
)
@@ -204,7 +204,7 @@ Usage
204204

205205
.. code:: python
206206
207-
tracer = Tracer(Klass.cmethod)
207+
tracer = malloc_tracer.Tracer(Klass.cmethod)
208208
tracer.trace(
209209
target_args=dict(var='Hello world.')
210210
)
@@ -219,7 +219,7 @@ Usage
219219
.. code:: python
220220
221221
import numpy as np
222-
from malloc_tracer.tracer import *
222+
import malloc_tracer
223223
224224
225225
global_var1 = None
@@ -254,10 +254,10 @@ Usage
254254
255255
.. code:: python
256256
257-
tracer = Tracer(func)
257+
tracer = malloc_tracer.Tracer(func)
258258
tracer.trace(
259259
target_args=dict(x=1, y=2, z=3),
260-
related_traces_output_mode=RelatedTracesOutputMode.FOR_EACH_FILE
260+
related_traces_output_mode=malloc_tracer.RelatedTracesOutputMode.FOR_EACH_FILE
261261
)
262262
263263
.. figure:: https://raw.githubusercontent.com/Hasenpfote/malloc_tracer/master/docs/usage3a.png
@@ -269,17 +269,27 @@ Usage
269269

270270
.. code:: python
271271
272-
tracer = Tracer(func)
272+
tracer = malloc_tracer.Tracer(func)
273273
tracer.trace(
274274
target_args=dict(x=1, y=2, z=3),
275-
related_traces_output_mode=RelatedTracesOutputMode.IN_DESCENDING_ORDER
275+
related_traces_output_mode=malloc_tracer.RelatedTracesOutputMode.IN_DESCENDING_ORDER
276276
)
277277
278278
.. figure:: https://raw.githubusercontent.com/Hasenpfote/malloc_tracer/master/docs/usage3b.png
279279
:alt: usage3b
280280

281281
usage3b
282282

283+
**Convenience function.**
284+
285+
.. code:: python
286+
287+
malloc_tracer.trace(
288+
func,
289+
target_args=dict(x=1, y=2, z=3),
290+
related_traces_output_mode=malloc_tracer.RelatedTracesOutputMode.IN_DESCENDING_ORDER
291+
)
292+
283293
License
284294
-------
285295

0 commit comments

Comments
 (0)