Merge pull request #701 from crytic/dev-perf

Add --perf flag
pull/704/head
Feist Josselin 4 years ago committed by GitHub
commit 4bd9c19991
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 17
      slither/__main__.py

@ -1,13 +1,16 @@
#!/usr/bin/env python3
import argparse
import cProfile
import glob
import inspect
import json
import logging
import os
import pstats
import sys
import traceback
from typing import Optional
from pkg_resources import iter_entry_points, require
@ -489,6 +492,10 @@ def parse_args(detector_classes, printer_classes):
default=defaults_flag_in_config["ignore_return_value"],
)
parser.add_argument(
"--perf", help=argparse.SUPPRESS, action="store_true", default=False,
)
# if the json is splitted in different files
parser.add_argument("--splitted", help=argparse.SUPPRESS, action="store_true", default=False)
@ -598,6 +605,11 @@ def main_impl(all_detector_classes, all_printer_classes):
logger.setLevel(logging.INFO)
args = parse_args(all_detector_classes, all_printer_classes)
cp: Optional[cProfile.Profile] = None
if args.perf:
cp = cProfile.Profile()
cp.enable()
# Set colorization option
set_colorization_enabled(not args.disable_color)
@ -773,6 +785,11 @@ def main_impl(all_detector_classes, all_printer_classes):
if outputting_zip:
output_to_zip(args.zip, output_error, json_results, args.zip_type)
if args.perf:
cp.disable()
stats = pstats.Stats(cp).sort_stats("cumtime")
stats.print_stats()
# Exit with the appropriate status code
if output_error:
sys.exit(-1)

Loading…
Cancel
Save