示例#1
0
def pool_runner(runner_args):
    (trial_type, bignum, a, divisor) = runner_args
    if trial_type == "basic":
        func = fastdivmod.divmod_iter_basic
        args = [bignum, divisor]
    elif trial_type == "def":
        func = fastdivmod.divmod_iter_chunking
        args = [bignum, divisor]
    elif trial_type == "auto":
        func = fastdivmod.divmod_iter
        args = [bignum, divisor]
    elif trial_type == "mult":
        chunk = fastdivmod.find_largest_power(sys.maxsize * a, divisor)
        func = fastdivmod.divmod_iter_chunking
        args = [bignum, divisor, chunk]
        if a < 1:
            trial_type = "%.2fmi" % (a, )
        else:
            trial_type = "%dmi" % (a, )

        if chunk <= divisor:
            return "n/a", trial_type

    elif trial_type == "pow":
        chunk = fastdivmod.find_largest_power(sys.maxsize**a, divisor)
        func = fastdivmod.divmod_iter_chunking
        args = [bignum, divisor, chunk]
        if a < 0:
            trial_type = "mi^%.2f" % (a, )
        else:
            trial_type = "mi^%d" % (a, )

        if chunk <= divisor:
            return "n/a", trial_type

    elif trial_type == "dpow":
        chunk = divisor**a
        func = fastdivmod.divmod_iter_chunking
        args = [bignum, divisor, chunk]
        if a < 0:
            trial_type = "d^%.2f" % (a, )
        else:
            trial_type = "d^%d" % (a, )
    try:
        return time_trial(func, args, {}), trial_type
    except Exception as e:
        print("\nException on", func, a, chunk, divisor, trial_type)
        traceback.print_exc()
        raise
示例#2
0
def pool_runner(runner_args):
    (trial_type, bignum, a, divisor) = runner_args
    if trial_type == 'basic':
        func = fastdivmod.divmod_iter_basic
        args = [bignum, divisor]
    elif trial_type == 'def':
        func = fastdivmod.divmod_iter_chunking
        args = [bignum, divisor]
    elif trial_type == 'auto':
        func = fastdivmod.divmod_iter
        args = [bignum, divisor]
    elif trial_type == 'mult':
        chunk = fastdivmod.find_largest_power(sys.maxsize * a, divisor)
        func = fastdivmod.divmod_iter_chunking
        args = [bignum, divisor, chunk]
        if a < 1:
            trial_type = '%.2fmi' % (a, )
        else:
            trial_type = '%dmi' % (a, )

        if chunk <= divisor:
            return 'n/a', trial_type

    elif trial_type == 'pow':
        chunk = fastdivmod.find_largest_power(sys.maxsize**a, divisor)
        func = fastdivmod.divmod_iter_chunking
        args = [bignum, divisor, chunk]
        if a < 0:
            trial_type = 'mi^%.2f' % (a, )
        else:
            trial_type = 'mi^%d' % (a, )

        if chunk <= divisor:
            return 'n/a', trial_type

    elif trial_type == 'dpow':
        chunk = divisor**a
        func = fastdivmod.divmod_iter_chunking
        args = [bignum, divisor, chunk]
        if a < 0:
            trial_type = 'd^%.2f' % (a, )
        else:
            trial_type = 'd^%d' % (a, )
    try:
        return time_trial(func, args, {}), trial_type
    except Exception as e:
        print("\nException on", func, a, chunk, divisor, trial_type)
        traceback.print_exc()
        raise
示例#3
0
def pool_runner((trial_type, bignum, a, divisor)):
    if trial_type == 'basic':
        func = fastdivmod.divmod_iter_basic
        args = [bignum, divisor]
    elif trial_type == 'def':
        func = fastdivmod.divmod_iter_chunking
        args = [bignum, divisor]
    elif trial_type == 'auto':
        func = fastdivmod.divmod_iter
        args = [bignum, divisor]
    elif trial_type == 'mult':
        chunk = fastdivmod.find_largest_power(sys.maxint * a, divisor)
        func = fastdivmod.divmod_iter_chunking
        args = [bignum, divisor, chunk]
        if a < 1:
            trial_type = '%.2fmi' % (a,)
        else:
            trial_type = '%dmi' % (a,)

        if chunk <= divisor:
            return 'n/a', trial_type

    elif trial_type == 'pow':
        chunk = fastdivmod.find_largest_power(sys.maxint ** a, divisor)
        func = fastdivmod.divmod_iter_chunking
        args = [bignum, divisor, chunk]
        if a < 0:
            trial_type = 'mi^%.2f' % (a,)
        else:
            trial_type = 'mi^%d' % (a,)

        if chunk <= divisor:
            return 'n/a', trial_type

    elif trial_type == 'dpow':
        chunk = divisor ** a
        func = fastdivmod.divmod_iter_chunking
        args = [bignum, divisor, chunk]
        if a < 0:
            trial_type = 'd^%.2f' % (a,)
        else:
            trial_type = 'd^%d' % (a,)
    try:
        return time_trial(func, args, {}), trial_type
    except Exception, e:
        print "\nException on", func, a, chunk, divisor, trial_type
        traceback.print_exc()
        raise