mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-08 07:39:33 +01:00
Here's the command I used to invoke autopep8 (in parallel!):
git ls-files | grep '\.py$' | xargs -n1 -P`nproc` autopep8 -i
Several rules are ignored in setup.cfg. The goal is to let autopep8
handle everything which it can handle safely, and to disable any rules
which are tricky or controversial to address. We may want to come back
and re-enable some of these rules later, but I'm trying to make this
patch as safe as possible.
Also configures flake8 to match pep8's behavior.
Also configures TravisCI to check the whole project for lint.
25 lines
626 B
Python
25 lines
626 B
Python
from __future__ import absolute_import
|
|
import time
|
|
|
|
from .monitor import Monitor
|
|
|
|
|
|
class TimeMonitor(Monitor):
|
|
stat_name = 'time'
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
kwargs.setdefault('unit', 'ms')
|
|
kwargs.setdefault('precision', 0)
|
|
super(TimeMonitor, self).__init__(*args, **kwargs)
|
|
self.last_time = None
|
|
|
|
def _get_value(self, *args):
|
|
if self.last_time:
|
|
now = time.time()
|
|
duration = now - self.last_time
|
|
self.last_time = now
|
|
return duration * 1000
|
|
else:
|
|
self.last_time = time.time()
|
|
return 0
|