コード例 #1
0
ファイル: profiles.py プロジェクト: mozilla/esFrontLine
    def __init__(self, description):
        from ..queries.windows import Stats

        if ON and not hasattr(self, "description"):
            self.description = description
            self.samples = []
            self.stats = Stats()()
            profiles[description] = self
コード例 #2
0
ファイル: profiles.py プロジェクト: klahnakoski/esFrontLine
    def __init__(self, description):
        from ..queries.windows import Stats

        if ON and not hasattr(self, "description"):
            self.description = description
            self.samples = []
            self.stats = Stats()()
            profiles[description] = self
コード例 #3
0
ファイル: profiles.py プロジェクト: klahnakoski/esFrontLine
class Profiler(object):
    """

    """

    def __new__(cls, *args):
        if ON:
            output = profiles.get(args[0], None)
            if output:
                return output
        output = object.__new__(cls, *args)
        return output

    def __init__(self, description):
        from ..queries.windows import Stats

        if ON and not hasattr(self, "description"):
            self.description = description
            self.samples = []
            self.stats = Stats()()
            profiles[description] = self

    def __enter__(self):
        if ON:
            self.start = clock()
        return self

    def __exit__(self, type, value, traceback):
        if ON:
            self.end = clock()
            duration = self.end - self.start

            from util.queries.windows import Stats

            self.stats.add(duration)
            if self.samples is not None:
                self.samples.append(duration)
                if len(self.samples) > 100:
                    self.samples = None
コード例 #4
0
ファイル: profiles.py プロジェクト: mozilla/esFrontLine
class Profiler(object):
    """

    """
    def __new__(cls, *args):
        if ON:
            output = profiles.get(args[0], None)
            if output:
                return output
        output = object.__new__(cls, *args)
        return output

    def __init__(self, description):
        from ..queries.windows import Stats

        if ON and not hasattr(self, "description"):
            self.description = description
            self.samples = []
            self.stats = Stats()()
            profiles[description] = self

    def __enter__(self):
        if ON:
            self.start = clock()
        return self

    def __exit__(self, type, value, traceback):
        if ON:
            self.end = clock()
            duration = self.end - self.start

            from util.queries.windows import Stats

            self.stats.add(duration)
            if self.samples is not None:
                self.samples.append(duration)
                if len(self.samples) > 100:
                    self.samples = None