fedora-python / fedora-python/python-ethtool

Slight growth of memory detected

Đang mở
#55 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
help wanted
Ngôn ngữ chính
C
Star
16
Fork
11
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

Get this script (GPLv2 Copyright (c) 2011 Red Hat):

```python
import ethtool
import subprocess, sys, os

max = int(sys.argv[1])
nic = sys.argv[2]
total = 0

def memory():
""" Get current memory usage in MB """
command = "ps --no-header -o rss -p %s" % os.getpid()
p = subprocess.Popen(command.split(), stdout=subprocess.PIPE)
stdout, stderr = p.communicate()
return int(stdout) / 1024

def measure(fun, arg):
""" Run given function on given arg max times """
global total
print("\n%s on %s" % (fun, arg))
start = None

for i in range(max + 1):
result = fun(arg)
if i % (max / 10) == 0:
current = memory()
# note the memory after the first round warm-up
if start is None:
start = current
print("%s %% ... %s MB" % \
(str(100 * i / max).rjust(3), str(current).rjust(3)))
increase = current - start
print("Memory increase: %s MB" % increase)
total += increase

measure(ethtool.get_active_devices, None)
measure(ethtool.get_interfaces_info, nic)
measure(ethtool.get_interfaces_info, 'bad interface name')

print("\nTotal memory increase: %s MB" % total)
if total > 0:
sys.exit(1)
```

And run:

```
$ python3.6 ~/tmp/memory.py 1000000 ens3
on None
0.0 % ... 10.1328125 MB
10.0 % ... 10.13671875 MB
20.0 % ... 10.13671875 MB
30.0 % ... 10.13671875 MB
40.0 % ... 10.13671875 MB
50.0 % ... 10.13671875 MB
60.0 % ... 10.13671875 MB
70.0 % ... 10.13671875 MB
80.0 % ... 10.13671875 MB
90.0 % ... 10.13671875 MB
100.0 % ... 10.13671875 MB
Memory increase: 0.00390625 MB

on ens3
0.0 % ... 10.13671875 MB
10.0 % ... 10.13671875 MB
20.0 % ... 10.13671875 MB
30.0 % ... 10.13671875 MB
40.0 % ... 10.13671875 MB
50.0 % ... 10.13671875 MB
60.0 % ... 10.13671875 MB
70.0 % ... 10.13671875 MB
80.0 % ... 10.13671875 MB
90.0 % ... 10.140625 MB
100.0 % ... 10.140625 MB
Memory increase: 0.00390625 MB

on bad interface name
0.0 % ... 10.140625 MB
10.0 % ... 10.140625 MB
20.0 % ... 10.140625 MB
30.0 % ... 10.140625 MB
40.0 % ... 10.140625 MB
50.0 % ... 10.140625 MB
60.0 % ... 10.140625 MB
70.0 % ... 10.140625 MB
80.0 % ... 10.140625 MB
90.0 % ... 10.140625 MB
100.0 % ... 10.140625 MB
Memory increase: 0.0 MB

Total memory increase: 0.0078125 MB
```

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.