Пример #1
0
 def __init__(self, obj, mode=None):
     self.obj = obj
     if mode is None:
         self.mode = ''
     else:
         self.mode = " (%s)" % (mode, )
     self.timer = TicTocTimer()
Пример #2
0
class TransformationTimer(object):
    fmt = "%%6.%df seconds to apply Transformation %s%s"
    def __init__(self, obj, mode=None):
        self.obj = obj
        if mode is None:
            self.mode = ''
        else:
            self.mode = " (%s)" % (mode,)
        self.timer = TicTocTimer()

    def report(self):
        # Record the elapsed time, as some log handlers may not
        # immediately generate the message string
        self.timer = self.timer.toc(msg="")
        _transform_logger.info(self)

    def __str__(self):
        total_time = self.timer
        name = self.obj.__class__.__name__
        try:
            return self.fmt % ( 2 if total_time>=0.005 else 0,
                                name,
                                self.mode,
                            ) % total_time
        except TypeError:
            return "TransformationTimer object for %s; %s elapsed seconds" % (
                name,
                self.timer.toc("") )
Пример #3
0
class TransformationTimer(object):
    fmt = "%%6.%df seconds to apply Transformation %s%s"

    def __init__(self, obj, mode=None):
        self.obj = obj
        if mode is None:
            self.mode = ''
        else:
            self.mode = " (%s)" % (mode, )
        self.timer = TicTocTimer()

    def report(self):
        # Record the elapsed time, as some log handlers may not
        # immediately generate the message string
        self.timer = self.timer.toc(msg="")
        _transform_logger.info(self)

    def __str__(self):
        total_time = self.timer
        name = self.obj.__class__.__name__
        try:
            return self.fmt % (
                2 if total_time >= 0.005 else 0,
                name,
                self.mode,
            ) % total_time
        except TypeError:
            return "TransformationTimer object for %s; %s elapsed seconds" % (
                name, self.timer.toc(""))
Пример #4
0
class ConstructionTimer(object):
    fmt = "%%6.%df seconds to construct %s %s; %d %s total"

    def __init__(self, obj):
        self.obj = obj
        self.timer = TicTocTimer()

    def report(self):
        # Record the elapsed time, as some log handlers may not
        # immediately generate the messge string
        self.timer = self.timer.toc(msg="")
        _construction_logger.info(self)

    def __str__(self):
        total_time = self.timer
        idx = len(self.obj.index_set())
        try:
            name = self.obj.name
        except RuntimeError:
            try:
                name = self.obj.local_name
            except RuntimeError:
                name = '(unknown)'
        try:
            return self.fmt % (
                2 if total_time >= 0.005 else 0,
                self.obj.type().__name__,
                name,
                idx,
                'indicies' if idx > 1 else 'index',
            ) % total_time
        except TypeError:
            return "ConstructionTimer object for %s %s; %s elapsed seconds" % (
                self.obj.type().__name__, name, self.timer.toc(""))
Пример #5
0
class ConstructionTimer(object):
    fmt = "%%6.%df seconds to construct %s %s; %d %s total"
    def __init__(self, obj):
        self.obj = obj
        self.timer = TicTocTimer()

    def report(self):
        # Record the elapsed time, as some log handlers may not
        # immediately generate the messge string
        self.timer = self.timer.toc(msg="")
        _construction_logger.info(self)

    def __str__(self):
        total_time = self.timer
        idx = len(self.obj.index_set())
        try:
            name = self.obj.name
        except RuntimeError:
            try:
                name = self.obj.local_name
            except RuntimeError:
                name = '(unknown)'
        try:
            return self.fmt % ( 2 if total_time>=0.005 else 0,
                                self.obj.type().__name__,
                                name,
                                idx,
                                'indicies' if idx > 1 else 'index',
                            ) % total_time
        except TypeError:
            return "ConstructionTimer object for %s %s; %s elapsed seconds" % (
                self.obj.type().__name__,
                name,
                self.timer.toc("") )
Пример #6
0
 def __init__(self, obj, mode=None):
     self.obj = obj
     if mode is None:
         self.mode = ''
     else:
         self.mode = " (%s)" % (mode,)
     self.timer = TicTocTimer()
Пример #7
0
 def __init__(self, obj):
     self.obj = obj
     self.timer = TicTocTimer()
Пример #8
0
# Copyright 2020 by B. Knueven, D. Mildebrath, C. Muir, J-P Watson, and D.L. Woodruff
# This software is distributed under the 3-clause BSD License.
import os
from pyutilib.misc.timing import TicTocTimer
try:
    import mpi4py.MPI as mpi
    haveMPI = True
except:
    haveMPI = False

tt_timer = TicTocTimer()

if haveMPI:
    global_rank = mpi.COMM_WORLD.Get_rank()
else:
    global_rank = 0

global_toc = lambda msg, cond=(global_rank == 0): tt_timer.toc(
    msg, delta=False) if cond else None
Пример #9
0
# Copyright 2020 by B. Knueven, D. Mildebrath, C. Muir, J-P Watson, and D.L. Woodruff
# This software is distributed under the 3-clause BSD License.
from pyutilib.misc.timing import TicTocTimer
try:
    import mpi4py.MPI as mpi
    haveMPI = True
except:
    haveMPI = False

tt_timer = TicTocTimer()
if not haveMPI or mpi.COMM_WORLD.Get_rank() == 0:
    tt_timer.toc("Initializing mpi-sppy", delta=False)
Пример #10
0
 def __init__(self, obj):
     self.obj = obj
     self.timer = TicTocTimer()