main: add timing ctx manager

This commit is contained in:
William Ballenthin
2021-11-04 12:20:05 -06:00
parent 0409c431b8
commit ed3bd4ef75

View File

@@ -10,6 +10,7 @@ See the License for the specific language governing permissions and limitations
"""
import os
import sys
import time
import hashlib
import logging
import os.path
@@ -17,6 +18,7 @@ import argparse
import datetime
import textwrap
import itertools
import contextlib
import collections
from typing import Any, Dict, List, Tuple
@@ -65,6 +67,14 @@ E_UNSUPPORTED_IDA_VERSION = -19
logger = logging.getLogger("capa")
@contextlib.contextmanager
def timing(msg: str):
t0 = time.time()
yield
t1 = time.time()
logger.debug("perf: %s: %0.2fs", msg, t1 - t0)
def set_vivisect_log_level(level):
logging.getLogger("vivisect").setLevel(level)
logging.getLogger("vivisect.base").setLevel(level)