本文整理匯總了Python中pympler.tracker.SummaryTracker方法的典型用法代碼示例。如果您正苦於以下問題:Python tracker.SummaryTracker方法的具體用法?Python tracker.SummaryTracker怎麽用?Python tracker.SummaryTracker使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pympler.tracker
的用法示例。
在下文中一共展示了tracker.SummaryTracker方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: memorytrack
# 需要導入模塊: from pympler import tracker [as 別名]
# 或者: from pympler.tracker import SummaryTracker [as 別名]
def memorytrack(func):
@functools.wraps(func)
def wrapper(*args, **kwargs):
from pympler import tracker
tr = tracker.SummaryTracker()
func(*args, **kwargs)
tr.print_diff()
return wrapper
示例2: __init__
# 需要導入模塊: from pympler import tracker [as 別名]
# 或者: from pympler.tracker import SummaryTracker [as 別名]
def __init__(self, initial_snapshot_name='Bootstrap'):
self._current_snapshot_name = initial_snapshot_name
self._diff_snapshot = False
self._tracker = tracker.SummaryTracker()
示例3: slave
# 需要導入模塊: from pympler import tracker [as 別名]
# 或者: from pympler.tracker import SummaryTracker [as 別名]
def slave():
new_model = make_model()
while 1:
#print('waiting for packet')
packet = comm.recv(source=0)
#comm.Recv(packet, source=0)
current_env_name = packet['current_env_name']
packet = packet['result']
assert(len(packet) == SOLUTION_PACKET_SIZE)
solutions = decode_solution_packet(packet)
results = []
#tracker2 = SummaryTracker()
new_model.make_env(current_env_name)
#tracker2.print_diff()
for solution in solutions:
worker_id, jobidx, seed, train_mode, max_len, weights = solution
assert (train_mode == 1 or train_mode == 0), str(train_mode)
worker_id = int(worker_id)
possible_error = "work_id = " + str(worker_id) + " rank = " + str(rank)
assert worker_id == rank, possible_error
jobidx = int(jobidx)
seed = int(seed)
fitness, timesteps = worker(weights, seed, max_len, new_model, train_mode)
results.append([worker_id, jobidx, fitness, timesteps])
new_model.env.close()
result_packet = encode_result_packet(results)
assert len(result_packet) == RESULT_PACKET_SIZE
comm.Send(result_packet, dest=0)
#print('slave: completed solutions')
示例4: startmemorytracker
# 需要導入模塊: from pympler import tracker [as 別名]
# 或者: from pympler.tracker import SummaryTracker [as 別名]
def startmemorytracker():
from pympler import tracker
tr = tracker.SummaryTracker()
return tr
示例5: on_epoch_end
# 需要導入模塊: from pympler import tracker [as 別名]
# 或者: from pympler.tracker import SummaryTracker [as 別名]
def on_epoch_end(self, epoch, log={}):
x = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
web_browser_debug = True
print(x)
if x > 40000:
if web_browser_debug:
if epoch==0:
start_in_background()
tr = tracker.SummaryTracker()
tr.print_diff()
else:
global memlist
all_objects = muppy.get_objects(include_frames=True)
# print(len(all_objects))
sum1 = summary.summarize(all_objects)
memlist.append(sum1)
summary.print_(sum1)
if len(memlist) > 1:
# compare with last - prints the difference per epoch
diff = summary.get_diff(memlist[-2], memlist[-1])
summary.print_(diff)
my_types = muppy.filter(all_objects, Type=types.ClassType)
for t in my_types:
print(t)
#########################################################
示例6: __init__
# 需要導入模塊: from pympler import tracker [as 別名]
# 或者: from pympler.tracker import SummaryTracker [as 別名]
def __init__(self, capture_interval=10, *args, **kwargs):
# type: (int, Any, Any) -> None
"""
:param capture_interval: How often to capture memory usage snapshot.
:type capture_interval: ``int``
"""
super(PeriodicMemorySummaryCaptureThread, self).__init__(
name="PeriodicMemorySummaryCaptureThread"
)
self._capture_interval = capture_interval
self._profiling_data = [] # type: List[Dict[str, Any]]
self._tracker = tracker.SummaryTracker()
示例7: dump_objs
# 需要導入模塊: from pympler import tracker [as 別名]
# 或者: from pympler.tracker import SummaryTracker [as 別名]
def dump_objs():
global TRACKER
if TRACKER is None:
TRACKER = tracker.SummaryTracker()
with open("obj_log.txt", "a") as fp:
fp.write("Memory at {}\n".format(str(datetime.datetime.now())))
try:
all_objects = muppy.get_objects()
sum1 = summary.summarize(all_objects)
str_sum = summary.format_(sum1)
fp.write("Summary:\n")
for line in str_sum:
fp.write(" {}\n".format(line))
except Exception:
err = traceback.format_exc()
fp.write("Error: \n")
fp.write(err)
try:
str_diff = TRACKER.format_diff()
fp.write("Diff:\n")
for line in str_diff:
fp.write(" {}\n".format(line))
except Exception:
err = traceback.format_exc()
fp.write("Error: \n")
fp.write(err)
fp.write("\n")