コード例 #1
0
ファイル: reference.py プロジェクト: jjkotni/faas-profiler
def main(params):
    pymem_setup_allocators(0)

    workers = len(params) if (len(params)>0) else 1

    runner  = pyperf.Runner(add_cmdline_args=add_cmdline_args, loops = 1)

    runner.argparser.add_argument("--cases",
                                  help="Comma separated list of cases. Available cases: %s. By default, run all cases."
                                      % ', '.join(CASES))

    runner.bench_func("Dummy init", dummyFunc, "main")

    del runner

    threads = []
    for i in range(workers):
        tname = 'Worker' + str(i)
        threads.append(threading.Thread(target=functionWorker, args=[i, tname,1], name=tname))

    for idx, thread in enumerate(threads):
        thread.start()
        thread.join()

    pymem_reset_pkru()

    result = {}
    for activation in params:
        result[activation] = "Finished thread execution"

    return(result)
コード例 #2
0
ファイル: __main__.py プロジェクト: jjkotni/faas-profiler
def main(params):
    pymem_setup_allocators()

    #workers = len(params) if (len(params)>0) else 1
    workers = params['workers'] if ('workers' in params) else 1

    runner = pyperf.Runner(add_cmdline_args=add_cmdline_args, loops=1)

    runner.argparser.add_argument(
        "--cases",
        help=
        "Comma separated list of cases. Available cases: %s. By default, run all cases."
        % ', '.join(CASES))
    threads = []
    for i in range(workers):
        tname = 'Worker' + str(i)
        threads.append(
            threading.Thread(target=functionWorker,
                             args=[runner, i, tname],
                             name=tname))

    for idx, thread in enumerate(threads):
        pkey_thread_mapper(thread.name)
        thread.start()
        thread.join()
    pymem_set_pkru(thread.name)

    result = {}
    for activation in params:
        result[activation] = "Finished thread execution"

    return (result)
コード例 #3
0
ファイル: __main__.py プロジェクト: jjkotni/faas-profiler
def main(params):
    # 3.8 changed the default event loop to ProactorEventLoop which doesn't
    # implement everything required by tornado and breaks this benchmark.
    # Restore the old WindowsSelectorEventLoop default for now.
    # https://bugs.python.org/issue37373
    # https://github.com/python/pyperformance/issues/61
    # https://github.com/tornadoweb/tornado/pull/2686
    nloops = ('loops' in params) and int(params['loops']) or 1
    workers = ('workers' in params) and int(params['workers']) or 1

    if sys.platform == 'win32' and sys.version_info[:2] == (3, 8):
        import asyncio
        asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())

    kw = {}
    kw['loops'] = nloops
    if pyperf.python_has_jit():
        # PyPy needs to compute more warmup values to warmup its JIT
        kw['warmups'] = 30
    runner = pyperf.Runner(**kw)

    threads = []
    for i in range(workers):
        threads.append(
            threading.Thread(target=functionWorker, args=[runner, i]))

    for idx, thread in enumerate(threads):
        thread.start()
        thread.join()

    out = 'Executed ' + str(workers) + ' threads'
    result = {'output': out}
    return (result)
コード例 #4
0
    def create_runner(self, args, **kwargs):
        # hack to be able to create multiple instances per process
        pyperf.Runner._created.clear()

        runner = pyperf.Runner(**kwargs)
        # disable CPU affinity to not pollute stdout
        runner._cpu_affinity = lambda: None
        runner.parse_args(args)
        return runner