How to use the yappi.start function in yappi

To help you get started, we’ve selected a few yappi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sumerc / yappi / tests / test_functionality.py View on Github external
def test_ctx_stats(self):
        from threading import Thread
        DUMMY_WORKER_COUNT = 5
        yappi.start()

        class DummyThread(Thread):
            pass

        def dummy():
            pass

        def dummy_worker():
            pass

        for i in range(DUMMY_WORKER_COUNT):
            t = DummyThread(target=dummy_worker)
            t.start()
            t.join()
        yappi.stop()
        stats = yappi.get_thread_stats()
github sumerc / yappi / tests / test_tags.py View on Github external
return tlocal._tag
            except Exception as e:
                #print(e)
                return -1

        def a(tag):
            tlocal._tag = tag

            burn_io(0.1)

        _TCOUNT = 20

        yappi.set_clock_type("wall")
        tlocal._tag = 0
        yappi.set_tag_callback(tag_cbk)
        yappi.start()

        ts = []
        for i in range(_TCOUNT):
            t = threading.Thread(target=a, args=(i + 1, ))
            ts.append(t)

        for t in ts:
            t.start()

        for t in ts:
            t.join()

        yappi.stop()

        traces = yappi.get_func_stats()
        t1 = '''
github sumerc / yappi / tests / test_tags.py View on Github external
def test_invalid_tag(self):

        def tag_cbk():
            return -1

        yappi.set_tag_callback(tag_cbk)
        yappi.start()
        tag_cbk()
        yappi.stop()
        stats = yappi.get_func_stats()
        stat = find_stat_by_name(stats, 'tag_cbk')
        self.assertEqual(stat.ncall, 1)
github sumerc / yappi / tests / test_functionality.py View on Github external
def thread_func():
            yappi.set_clock_type("wall")
            yappi.start()

            bar()
github ArduPilot / pymavlink / tools / mavlogdump.py View on Github external
parser.add_argument("log", metavar="LOG")
parser.add_argument("--profile", action='store_true', help="run the Yappi python profiler")

args = parser.parse_args()

if not args.mav10:
    os.environ['MAVLINK20'] = '1'

import inspect

from pymavlink import mavutil


if args.profile:
    import yappi    # We do the import here so that we won't barf if run normally and yappi not available
    yappi.start()

filename = args.log
mlog = mavutil.mavlink_connection(filename, planner_format=args.planner,
                                  notimestamps=args.notimestamps,
                                  robust_parsing=args.robust,
                                  dialect=args.dialect,
                                  zero_time_base=args.zero_time_base)

output = None
if args.output:
    output = open(args.output, mode='wb')

types = args.types
if types is not None:
    types = types.split(',')
github spartan-array / spartan / spartan / master.py View on Github external
self._port = port
    self._server = rpc.listen('0.0.0.0', port)
    self._server.register_object(self)
    self._initialized = False
    self._server.serve_nonblock()
    self._ctx = None

    self._worker_statuses = {}
    self._worker_scores = {}
    self._available_workers = []

    self._arrays = weakref.WeakSet()

    if FLAGS.profile_master:
      import yappi
      yappi.start()
      atexit.register(_dump_profile)
    atexit.register(_shutdown)

    global MASTER
    MASTER = self
github bgribble / mfp / mfp / mfp_main.py View on Github external
continue

        try:
            os.stat(fullpath)
        except OSError:
            log.debug("initfile: Error accessing file", fullpath)
            continue
        try:
            evaluator.exec_file(fullpath)
        except Exception as e:
            log.debug("initfile: Exception while loading initfile", f)
            log.debug(e)

    if app.debug:
        import yappi
        yappi.start()

    if args.get("help"):
        log.log_debug = None
        log.log_file = None
        log.debug("printing help and exiting")
        parser.print_help()
        log.debug("done with print_help(), quitting")
        app.finish()
    elif args.get("help_builtins"):
        log.log_debug = None
        log.log_file = None
        app.open_file(None)
        for name, factory in sorted(app.registry.items()):
            if hasattr(factory, 'doc_tooltip_obj'):
                print("%-12s : %s" % ("[%s]" % name, factory.doc_tooltip_obj))
            else:
github opendatacube / datacube-core / examples / band_stats_dask.py View on Github external
def main(argv):
    import yappi
    yappi.start(builtins=True)

    lon = int(argv[1])
    lat = int(argv[2])
    dt = numpy.datetime64(argv[3])

    stack = _get_dataset(lon, lat)
    pqa = _get_dataset(lon, lat, dataset='PQA')

    # TODO: this needs to propagate somehow from the input to the output
    geotr = stack._storage_units[0]._storage_unit._storage_unit._transform
    proj = stack._storage_units[0]._storage_unit._storage_unit._projection

    qs = [10, 50, 90]
    num_workers = 16
    N = 4000//num_workers
github nocproject / noc / core / management / base.py View on Github external
"""
        parser = self.create_parser()
        self.add_default_arguments(parser)
        self.add_arguments(parser)
        options = parser.parse_args(argv)
        cmd_options = vars(options)
        args = cmd_options.pop("args", ())
        loglevel = cmd_options.pop("loglevel")
        if loglevel:
            self.setup_logging(loglevel)
        enable_profiling = cmd_options.pop("enable_profiling", False)
        show_metrics = cmd_options.pop("show_metrics", False)
        if enable_profiling:
            # Start profiler
            import yappi
            yappi.start()
        try:
            return self.handle(*args, **cmd_options) or 0
        except CommandError as e:
            self.print(str(e))
            return 1
        except KeyboardInterrupt:
            self.print("Ctrl+C")
            return 3
        except AssertionError as e:
            if e.args[0]:
                self.print("ERROR: %s" % e.args[0])
            else:
                self.print("Assertion error")
            return 4
        except Exception:
            error_report()