How to use the c2cwsgiutils.stats.timer function in c2cwsgiutils

To help you get started, we’ve selected a few c2cwsgiutils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github camptocamp / tilecloud-chain / tilecloud_chain / timedtilestore.py View on Github external
def _time_iteration(self, generator, func_name):
        while True:
            timer = stats.timer()
            try:
                tile = next(generator)
            except StopIteration:
                break
            except RuntimeError as e:
                if isinstance(e.__cause__, StopIteration):
                    # since python 3.7, a StopIteration is wrapped in a RuntimeError (PEP 479)
                    break
                else:
                    raise
            timer.stop(self._get_stats_name(func_name, tile))
            yield tile
github camptocamp / tilecloud / tilecloud / filter / benchmark.py View on Github external
def callback(tile):
            if tile:
                if hasattr(tile, self.attr):
                    timer = getattr(tile, self.attr)
                    delta_t = timer.stop()
                    if statistics:
                        statistics.add(delta_t)
                else:
                    setattr(tile, self.attr, stats.timer([key]))
            return tile