FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
fluentpython-example-code/09-pythonic-obj/mem_test.py at master · josenaldo/fluentpython-example-code · GitHub
josenaldo
/
fluentpython-example-code
Public
forked from
fluentpython/example-code
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
fluentpython-example-code
/
09-pythonic-obj
/
mem_test.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
24 lines (18 loc) · 727 Bytes
Breadcrumbs
fluentpython-example-code
/
09-pythonic-obj
/
mem_test.py
Copy path
File metadata and controls
24 lines (18 loc) · 727 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import
importlib
import
sys
import
resource
NUM_VECTORS
=
10
**
7
if
len
(
sys
.
argv
)
==
2
:
module_name
=
sys
.
argv
[
1
].
replace
(
'.py'
,
''
)
module
=
importlib
.
import_module
(
module_name
)
else
:
print
(
'Usage: {} <vector-module-to-test>'
.
format
())
sys
.
exit
(
1
)
fmt
=
'Selected Vector2d type: {.__name__}.{.__name__}'
print
(
fmt
.
format
(
module
,
module
.
Vector2d
))
mem_init
=
resource
.
getrusage
(
resource
.
RUSAGE_SELF
).
ru_maxrss
print
(
'Creating {:,} Vector2d instances'
.
format
(
NUM_VECTORS
))
vectors
=
[
module
.
Vector2d
(
3.0
,
4.0
)
for
i
in
range
(
NUM_VECTORS
)]
mem_final
=
resource
.
getrusage
(
resource
.
RUSAGE_SELF
).
ru_maxrss
print
(
'Initial RAM usage: {:14,}'
.
format
(
mem_init
))
print
(
' Final RAM usage: {:14,}'
.
format
(
mem_final
))
Back
|
FazBrowse Home
|
New Git URL