当前位置: 首页>>代码示例>>Python>>正文


Python summary.get_diff方法代码示例

本文整理汇总了Python中pympler.summary.get_diff方法的典型用法代码示例。如果您正苦于以下问题:Python summary.get_diff方法的具体用法?Python summary.get_diff怎么用?Python summary.get_diff使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pympler.summary的用法示例。


在下文中一共展示了summary.get_diff方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: diff

# 需要导入模块: from pympler import summary [as 别名]
# 或者: from pympler.summary import get_diff [as 别名]
def diff(self, summary1=None, summary2=None):
        """Compute diff between to summaries.

        If no summary is provided, the diff from the last to the current
        summary is used. If summary1 is provided the diff from summary1
        to the current summary is used. If summary1 and summary2 are
        provided, the diff between these two is used.

        """
        res = None
        if summary2 is None:
            self.s1 = self.create_summary()
            if summary1 is None:
                res = summary.get_diff(self.s0, self.s1)
            else:
                res = summary.get_diff(summary1, self.s1)
            self.s0 = self.s1
        else:
            if summary1 is not None:
                res = summary.get_diff(summary1, summary2)
            else:
                raise ValueError("You cannot provide summary2 without summary1.")
        return summary._sweep(res) 
开发者ID:lrq3000,项目名称:pyFileFixity,代码行数:25,代码来源:tracker.py

示例2: print_muppy_sumary

# 需要导入模块: from pympler import summary [as 别名]
# 或者: from pympler.summary import get_diff [as 别名]
def print_muppy_sumary():
    # http://pythonhosted.org/Pympler/index.html
    try:
        from pympler import muppy, summary
    except ImportError:
        print("WARNING: pympler not installed")
        return
    # from pympler.classtracker import ClassTracker
    # from pympler.classtracker_stats import HtmlStats
    global all_objects, obj_summary, class_tracker
    if all_objects is None:
        all_objects = muppy.get_objects()
        obj_summary = summary.summarize(all_objects)
        summary.print_(obj_summary)

        # class_tracker = ClassTracker()
        # class_tracker.track_class(FICSPlayer, trace=1)
        # class_tracker.track_class(ICGameModel, resolution_level=2, trace=1)
    else:
        obj_summary2 = summary.summarize(muppy.get_objects())
        diff = summary.get_diff(obj_summary, obj_summary2)
        summary.print_(diff, limit=200)

        # class_tracker.create_snapshot('usage')
        # HtmlStats(tracker=class_tracker).create_html('profile.html') 
开发者ID:pychess,项目名称:pychess,代码行数:27,代码来源:debug.py

示例3: get_diff

# 需要导入模块: from pympler import summary [as 别名]
# 或者: from pympler.summary import get_diff [as 别名]
def get_diff(left, right):
    """Get the difference of both lists.

    The result will be a dict with this form {'+': [], '-': []}.
    Items listed in '+' exist only in the right list,
    items listed in '-' exist only in the left list.

    """
    res = {'+': [], '-': []}

    def partition(objects):
        """Partition the passed object list."""
        res = {}
        for o in objects:
            t = type(o)
            if type(o) not in res:
                res[t] = []
            res[t].append(o)
        return res

    def get_not_included(foo, bar):
        """Compare objects from foo with objects defined in the values of
        bar (set of partitions).
        Returns a list of all objects included in list, but not dict values.
        """
        res = []
        for o in foo:
            if not compat.object_in_list(type(o), bar):
                res.append(o)
            elif not compat.object_in_list(o, bar[type(o)]):
                res.append(o)
        return res

    # Create partitions of both lists. This will reduce the time required for
    # the comparison
    left_objects = partition(left)
    right_objects = partition(right)
    # and then do the diff
    res['+'] = get_not_included(right, left_objects)
    res['-'] = get_not_included(left, right_objects)
    return res 
开发者ID:lrq3000,项目名称:pyFileFixity,代码行数:43,代码来源:muppy.py

示例4: get_diff

# 需要导入模块: from pympler import summary [as 别名]
# 或者: from pympler.summary import get_diff [as 别名]
def get_diff(self, ignore=[]):
        """Get the diff to the last time the  state of objects was measured.

        keyword arguments
        ignore -- list of objects to ignore
        """
        # ignore this and the caller frame
        ignore.append(inspect.currentframe()) #PYCHOK change ignore
        self.o1 = self._get_objects(ignore)
        diff = muppy.get_diff(self.o0, self.o1)
        self.o0 = self.o1
        # manual cleanup, see comment above
        del ignore[:] #PYCHOK change ignore
        return diff 
开发者ID:lrq3000,项目名称:pyFileFixity,代码行数:16,代码来源:tracker.py

示例5: print_diff

# 需要导入模块: from pympler import summary [as 别名]
# 或者: from pympler.summary import get_diff [as 别名]
def print_diff(self, ignore=[]):
        """Print the diff to the last time the state of objects was measured.

        keyword arguments
        ignore -- list of objects to ignore
        """
        # ignore this and the caller frame
        ignore.append(inspect.currentframe()) #PYCHOK change ignore
        diff = self.get_diff(ignore)
        print("Added objects:")
        summary.print_(summary.summarize(diff['+']))
        print("Removed objects:")
        summary.print_(summary.summarize(diff['-']))
        # manual cleanup, see comment above
        del ignore[:] 
开发者ID:lrq3000,项目名称:pyFileFixity,代码行数:17,代码来源:tracker.py

示例6: on_epoch_end

# 需要导入模块: from pympler import summary [as 别名]
# 或者: from pympler.summary import get_diff [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)


    ######################################################### 
开发者ID:robmsmt,项目名称:KerasDeepSpeech,代码行数:31,代码来源:utils.py

示例7: snapshot_diff

# 需要导入模块: from pympler import summary [as 别名]
# 或者: from pympler.summary import get_diff [as 别名]
def snapshot_diff(cur_items, snapshot_file):
    """
    Attempts to compare like PIDs. If like PIDS can't be found it will just compare
    the first PID listed to the first PID in the file. Any unmatched or non-first
    PIDs will be ignored because we don't know what to compare them to.
    """
    try:
        prev_items = list(frontend_utils.get_pages(snapshot_file))
    except pickle.UnpicklingError as e:
        frontend_utils.echo_error(
            f"Error unpickling the data from {snapshot_file}: {e}"
        )
        return None

    differences = []
    for cur_item in cur_items:
        for prev_item in prev_items:
            if cur_item.pid == prev_item.pid:
                diff = summary.get_diff(cur_item.data, prev_item.data)
                differences.append(
                    RetrievedObjects(
                        pid=cur_item.pid,
                        title=f"Snapshot Differences for {cur_item.pid}",
                        data=diff,
                    )
                )
    if not differences:
        diff = summary.get_diff(cur_items[0].data, prev_items[0].data)
        differences.append(
            RetrievedObjects(pid=0, title=f"Snapshot Differences", data=diff)
        )
    return differences 
开发者ID:facebookincubator,项目名称:memory-analyzer,代码行数:34,代码来源:analysis_utils.py


注:本文中的pympler.summary.get_diff方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。