本文整理汇总了Python中line_profiler.LineProfiler.dump_stats方法的典型用法代码示例。如果您正苦于以下问题:Python LineProfiler.dump_stats方法的具体用法?Python LineProfiler.dump_stats怎么用?Python LineProfiler.dump_stats使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类line_profiler.LineProfiler
的用法示例。
在下文中一共展示了LineProfiler.dump_stats方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: wrapper
# 需要导入模块: from line_profiler import LineProfiler [as 别名]
# 或者: from line_profiler.LineProfiler import dump_stats [as 别名]
def wrapper(*args, **kwargs):
# Don't profile if debugging is off (PROD server mode)
if DEBUG:
logger.error('Line Profiling (@profile_this_by_line) ' + func.__name__ + '() to ' + stats_filename + '.')
profiler = LineProfiler()
profiled_func = profiler(func)
try:
retval = profiled_func(*args, **kwargs)
finally:
# profiler.print_stats()
profiler.dump_stats(stats_filename)
else:
logger.error('Line Profiling (@profile_this_by_line) attempted on ' + func.__name__ + '() while in production mode. Profiling Bypassed.')
retval = func(*args, **kwargs)
return retval
示例2: main
# 需要导入模块: from line_profiler import LineProfiler [as 别名]
# 或者: from line_profiler.LineProfiler import dump_stats [as 别名]
def main():
profiler = cProfile.Profile()
profiler.enable()
function_runner('original_method')
function_runner('step_one')
function_runner('step_two')
function_runner('step_three')
function_runner('step_four')
function_runner('step_five')
function_runner('step_six')
function_runner('step_seven')
function_runner('step_eight')
function_runner('step_nine')
function_runner('current')
profiler.disable()
profiler.dump_stats('function_event.stats')
line_profiler = LineProfiler(CurrentFunctionContainer().current)
line_profiler.enable()
function_runner('current')
line_profiler.disable()
line_profiler.dump_stats('function_event.line_stats')
line_profiler.print_stats()
print 'Original', timeit.timeit(
lambda: function_runner('original_method'), number=7)
print 'One', timeit.timeit(
lambda: function_runner('step_one'), number=7)
print 'Two', timeit.timeit(
lambda: function_runner('step_two'), number=7)
print 'Three', timeit.timeit(
lambda: function_runner('step_three'), number=7)
print 'Four', timeit.timeit(
lambda: function_runner('step_four'), number=7)
print 'Five', timeit.timeit(
lambda: function_runner('step_five'), number=7)
print 'Six', timeit.timeit(
lambda: function_runner('step_six'), number=7)
print 'Seven', timeit.timeit(
lambda: function_runner('step_seven'), number=7)
print 'Eight', timeit.timeit(
lambda: function_runner('step_eight'), number=7)
print 'Nine', timeit.timeit(
lambda: function_runner('step_nine'), number=7)
print 'Current', timeit.timeit(
lambda: function_runner('current'), number=7)
示例3: LineProfiler
# 需要导入模块: from line_profiler import LineProfiler [as 别名]
# 或者: from line_profiler.LineProfiler import dump_stats [as 别名]
properties[i].append(objects[j].moments_hu())
properties[i].append(objects[j].image())
properties[i].append(objects[j].label)
properties[i].append(objects[j].major_axis_length())
properties[i].append(objects[j].max_intensity())
properties[i].append(objects[j].mean_intensity())
properties[i].append(objects[j].min_intensity())
properties[i].append(objects[j].minor_axis_length())
properties[i].append(objects[j].moments())
properties[i].append(objects[j].moments_normalized())
properties[i].append(objects[j].orientation())
properties[i].append(objects[j].perimeter())
properties[i].append(objects[j].solidity())
properties[i].append(objects[j].weighted_moments_central())
properties[i].append(objects[j].weighted_centroid())
properties[i].append(objects[j].weighted_moments_hu())
properties[i].append(objects[j].weighted_moments())
properties[i].append(objects[j].weighted_moments_normalized())
return properties, prop_names
if __name__ == '__main__':
image = io.imread('test-image.png')
green = image[..., 1].copy()
lp = LineProfiler()
lp.add_function(object_features)
lp.run('intensity_object_features(green, 100)')
lp.print_stats()
lp.dump_stats('profile.lprof')
print(__file__)
示例4: zip
# 需要导入模块: from line_profiler import LineProfiler [as 别名]
# 或者: from line_profiler.LineProfiler import dump_stats [as 别名]
for timestamp in bit_2_events[-5:]:
print "unstrobed bit 2 t=%f" % timestamp
print "found %d bit 3 events. Last 5 events are:" %(len(bit_3_events))
for timestamp in bit_3_events[-5:]:
print "unstrobed bit 3 t=%f" % timestamp
unstrobed_word = pu.GetExtEvents(data, event='unstrobed_word', online=False)
print "found %d unstrobed word events in which 10 events are:" %(len(unstrobed_word['value']))
indices = np.arange(0,len(unstrobed_word['value']),len(unstrobed_word['value'])/10)
for value,timestamp in zip(unstrobed_word['value'][indices],unstrobed_word['timestamp'][indices]) :
binary_value = bin(value)
print "unstrobed word:%s t=%f" % (binary_value,timestamp)
if __name__ == "__main__":
#run()
profile = LineProfiler()
profile.add_function(run)
profile.add_function(PlexUtil.GetExtEvents)
profile.add_function(reconstruct_word)
profile.run('run()')
profile.print_stats()
profile.dump_stats("testPlexFile_profile.lprof")
#cProfile.run('run()','PlexFile_profile')
#p = pstats.Stats('testPlexFile_profile.lprof')
#p.sort_stats('cumulative')
#p.print_stats()
#print h.heap()
示例5: Copyright
# 需要导入模块: from line_profiler import LineProfiler [as 别名]
# 或者: from line_profiler.LineProfiler import dump_stats [as 别名]
# Test and profile TimeHistogram
#
# Copyright (C) 2010-2012 Huang Xin
#
# See LICENSE.TXT that came with this file.
#import cProfile,pstats
from line_profiler import LineProfiler
import TimeHistogram
def run():
psth = TimeHistogram.PSTHAverage('/home/chrox/dev/plexon_data/c04-stim-timing-8ms-rand-1.plx')
psth.get_data()
if __name__ == '__main__':
#cProfile.run('psth.get_data()','hist_profile')
#p = pstats.Stats('hist_profile')
#p.sort_stats('cumulative')
#p.print_stats()
profile = LineProfiler()
profile.add_function(run)
profile.add_function(TimeHistogram.PSTHAverage._process_unit)
profile.run('run()')
profile.print_stats()
profile.dump_stats("hist_profile.lprof")