diff --git a/capa/main.py b/capa/main.py index d610f383..9bf45ecc 100644 --- a/capa/main.py +++ b/capa/main.py @@ -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)