mirror of
https://github.com/hpcaitech/ColossalAI.git
synced 2025-09-08 04:24:47 +00:00
[misc] update pre-commit and run all files (#4752)
* [misc] update pre-commit * [misc] run pre-commit * [misc] remove useless configuration files * [misc] ignore cuda for clang-format
This commit is contained in:
@@ -2,12 +2,12 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
import time
|
||||
from typing import Tuple
|
||||
|
||||
from .cuda import synchronize
|
||||
|
||||
|
||||
class Timer:
|
||||
"""A timer object which helps to log the execution times, and provides different tools to assess the times.
|
||||
"""
|
||||
"""A timer object which helps to log the execution times, and provides different tools to assess the times."""
|
||||
|
||||
def __init__(self):
|
||||
self._started = False
|
||||
@@ -25,16 +25,14 @@ class Timer:
|
||||
return time.time()
|
||||
|
||||
def start(self):
|
||||
"""Firstly synchronize cuda, reset the clock and then start the timer.
|
||||
"""
|
||||
"""Firstly synchronize cuda, reset the clock and then start the timer."""
|
||||
self._elapsed = 0
|
||||
synchronize()
|
||||
self._start_time = time.time()
|
||||
self._started = True
|
||||
|
||||
def lap(self):
|
||||
"""lap time and return elapsed time
|
||||
"""
|
||||
"""lap time and return elapsed time"""
|
||||
return self.current_time - self._start_time
|
||||
|
||||
def stop(self, keep_in_history: bool = False):
|
||||
@@ -80,12 +78,11 @@ class Timer:
|
||||
Note:
|
||||
Use it only when timer is not in progress
|
||||
"""
|
||||
assert not self._started, 'Timer is still in progress'
|
||||
assert not self._started, "Timer is still in progress"
|
||||
return self._elapsed
|
||||
|
||||
def reset(self):
|
||||
"""Clear up the timer and its history
|
||||
"""
|
||||
"""Clear up the timer and its history"""
|
||||
self._history = []
|
||||
self._started = False
|
||||
self._elapsed = 0
|
||||
|
Reference in New Issue
Block a user