Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(1)  |  Call(0)  |  Derive(0)  |  Import(1)
Call maker main

:param call_maker_class: Call maker job class
:param args: args
:param logger: logger
:param kwargs: kwargs for job manager

        def callmaker_main(call_maker_class, args=None, logger=None, **kwargs):
    """Call maker main

    :param call_maker_class: Call maker job class
    :param args: args
    :param logger: logger
    :param kwargs: kwargs for job manager
    """
    if args is None:
        arg_parse = callmaker_argparse(argparse.ArgumentParser('Call maker'))
        args = arg_parse.parse_args()

    if args.verbose:
        log_level = logging.DEBUG
    else:
        log_level = logging.WARNING

    if not logger:
        logging.basicConfig(
            format="%(asctime)s [%(process)d] %(levelname)s: %(message)s",
            level=log_level,


            filename=args.log_file
        )

        logger = logging.getLogger()

    def print_result(job_manager):
        call_sum = 0
        call_fail_sum = 0
        max_time = 0
        max_time_real = 0
        rs_sum = 0
        ers_sum = 0
        seeds = []

        str = "=========\n"
        str += "Processes\n"
        str += "=========\n\n"

        def safe_div(a, b, default=0):
            try:
                return a / float(b)
            except ZeroDivisionError:
                return default

        for w, r in job_manager.results():
            rs = safe_div(r['call_count'], r['elapsed_time_real'])
            ers = safe_div(r['call_fail_count'], r['elapsed_time_real'])

            elapsed = r['elapsed_time']
            elapsed_real = r['elapsed_time_real']

            rs_sum += rs
            ers_sum += ers
            call_sum += r['call_count']
            call_fail_sum += r['call_fail_count']

            success = r['call_count'] - r['call_fail_count']

            seeds.append(r['seed'])

            if elapsed > max_time:
                max_time = elapsed

            if elapsed_real > max_time_real:
                max_time_real = elapsed_real

            str += "%d\n" % w.pid
            str += "----\n"
            str += " - Time (CPU): %f\n" % elapsed
            str += " - Time elapsed: %f\n" % elapsed_real

            str += " - Requests: %d\n" % r['call_count']
            str += ' - Success: %d (%d%%)\n' % (success, safe_div(success, call_sum) * 100.0)
            str += ' - Fail: %d (%d%%)\n' % (
                r['call_fail_count'], safe_div(r['call_fail_count'], r['call_count']) * 100.0
            )

            str += " - request/s: %f\n" % rs
            str += " - error request/s: %f\n" % ers

            str += " - Seed : %f\n" % r['seed']

            str += "\n"

        success = call_sum - call_fail_sum

        str += "=======\n"
        str += "Summary\n"
        str += "=======\n"
        str += ' - Job count: %d\n' % job_manager.job_count
        str += ' - Reapeats: %d\n' % args.job_repeat_count
        str += ' - Job call count: %d\n' % (args.job_call_count if args.job_call_count > -1 else len(call_list))
        str += ' - Call list size: %d\n' % len(call_list)

        str += ' - Requests: %d\n' % call_sum
        str += ' - Success: %d (%d%%)\n' % ( success, safe_div(success, call_sum) * 100.0)
        str += ' - Fail: %d (%d%%)\n' % ( call_fail_sum, safe_div(call_fail_sum, call_sum) * 100.0)

        str += ' - Max time (CPU): %f\n' % max_time
        str += " - Max time: %f\n" % max_time_real

        str += ' - request/s: %f\n' % safe_div(call_sum, max_time_real)
        str += ' - error request/s: %f\n' % safe_div(call_fail_sum, max_time_real)

        str += ' - AVG request/s: %f\n' % safe_div(rs_sum, job_manager.job_count)
        str += ' - AVG error request/s: %f\n' % safe_div(ers_sum, job_manager.job_count)

        str += ' - Seeds: %s\n' % ('%f ' * len(seeds)) % tuple(seeds)

        print str

    call_list = CallMaker.file_to_callist(args.call_list_file)

    if args.ignore_call:
        call_list = remove_ignore_calls(call_list, args.ignore_call, logger)

    jm = JobManager(call_maker_class)
    jm.start(
        job_count=args.job_count,
        call_list=tuple(call_list),
        repeat_count=args.job_repeat_count,
        call_count=args.job_call_count,
        seeds=args.seeds,
        **kwargs
    )

    print_result(jm)
        


src/c/e/cejob-0.0.6/src/cejob/ext/__init__.py   cejob(Download)
from cejob.ext.call_maker import CallMaker, callmaker_main, callmaker_argparse