Skip to content

Commit

Permalink
Calculate time elapsed using time.perf_counter.
Browse files Browse the repository at this point in the history
This makes --verbose-timing more useful to see which linter is falling
behind.

Signed-off-by: Zixuan James Li <[email protected]>
  • Loading branch information
PIG208 authored and timabbott committed Sep 7, 2023
1 parent a3ed087 commit 3ef6670
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions zulint/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import logging
import multiprocessing
import sys
import time
import weakref
from typing import Callable, Dict, List, Mapping, NoReturn, Sequence, Set, Tuple, Union

Expand Down Expand Up @@ -57,9 +58,11 @@ def split_arg_into_list(arg: str) -> List[str]:
def run_parallel_worker(item: Tuple[str, int]) -> Tuple[str, int]:
name, func_id = item
func = run_parallel_functions[func_id]
logging.info("start " + name)
logging.info("start {}".format(name))
time_start = time.perf_counter()
result = func()
logging.info("finish " + name)
time_end = time.perf_counter()
logging.info("finish {}; elapsed time: {}".format(name, time_end - time_start))
sys.stdout.flush()
sys.stderr.flush()
return name, result
Expand Down

0 comments on commit 3ef6670

Please sign in to comment.