예제 #1
0
def benchmark():
    """
    Run all of the benchmarks registered in the benchmarkFuncs list
    """
    print defer.Deferred.__module__
    for func, args, iter in benchmarkFuncs:
        print func.__name__, args, timeit(func, iter, *args)
예제 #2
0
파일: defer.py 프로젝트: anrysev/twisted
def benchmark():
    """
    Run all of the benchmarks registered in the benchmarkFuncs list
    """
    print defer.Deferred.__module__
    for func, args, iter in benchmarkFuncs:
        print func.__name__, args, timeit(func, iter, *args)
예제 #3
0
파일: cutstock.py 프로젝트: pratikac/16.763
def average_speedup_expt():
    '''
    run on instances of large and larger n, take average of runtimes
    '''
    N = range(1,10)
    t_colgen = []
    t_mip = []
    
    t_solve_colgen = timer.timeit(solve_column_generation)
    t_solve_mip = timer.timeit(solve_MIP)
    for n in N:
        s, B = create_example(random=True, n=10*n)
        t_colgen.append(t_solve_colgen(s,B))
        t_mip.append(t_solve_mip(s,B))
        print n

    print t_colgen, t_mip
예제 #4
0
    def record(self, cmd, title):
        duration, stdout = timer.timeit(self.pty_recorder.record_command,
                                        cmd or self.env['SHELL'])

        asciicast = Asciicast()
        asciicast.title = title
        asciicast.command = cmd
        asciicast.stdout = stdout
        asciicast.duration = duration

        return asciicast
예제 #5
0
#!/usr/bin/python

from timer import timeit
from twisted.spread.banana import b1282int

ITERATIONS = 100000

for length in (1, 5, 10, 50, 100):
    elapsed = timeit(b1282int, ITERATIONS, "\xff" * length)
    print("b1282int %3d byte string: %10d cps" % (length, ITERATIONS / elapsed))
예제 #6
0
if __name__ == "__main__":
    from timer import timeit

    kwargs = {"low": -5, "high": 5, "npts": 50000}

    # Python
    import pymod

    timep, resultp = timeit(pymod.integrate, iters=200, **kwargs)
    print(f"Python: time = {timep:.4f}s, result = {resultp:.4f}")

    # Cython
    import cymod

    timec, resultc = timeit(cymod.integrate, iters=200, **kwargs)
    print(f"Cython: time = {timec:.4f}s, result = {resultc:.4f}")

    # Relative speedup
    print(f"Cython/python speedup: {timep/timec}")
예제 #7
0
    def test_timeit(self):
        duration, return_value = timeit(lambda *args: args, 1, 'two', True)

        assert_equal(14.57, duration)
        assert_equal((1, 'two', True), return_value)
예제 #8
0
        try:
            eval('deepFailure%d_0' % n)()
        except:
            str(failure.Failure())


class PythonException(Exception):
    pass


def fail_easy(n):
    for i in R:
        try:
            failure.Failure(PythonException())
        except:
            pass


from timer import timeit
# for i in O:
#     timeit(fail, 1, i)

# for i in O:
#     print('easy failing', i, timeit(fail_easy, 1, i))

for i in O:
    print('failing', i, timeit(fail, 1, i))

# for i in O:
#     print('string failing', i, timeit(fail_str, 1, i))
예제 #9
0
파일: task.py 프로젝트: Almad/twisted
def main():
    print "LoopingCall large advance takes", timeit(test_performance, iter=1)

def interpolate(grid, points, values):
    """ Given a grid, raw data points, and values interpolate the
    data to fit on the grid.
    """
    return griddata(points, values, grid, method=method)


def main():
    import sys, time
    try:
        interval, input_filename, output_filename = sys.argv[1:4]
    except ValueError:
        print('Usage: python interpolater.py <interval> <input_file>, <output_file>')
    with open(input_filename) as f, open(output_filename, 'w') as o:
        data = []
        # Ignore first line
        f.readline()
        for line in f:
            t, x, y, z = line.split(',')
            data.append((int(time), int(x), int(y), int(z)))
        grid = [range(len(data)) for i in range(3)]

        o_data = interpolate(grid, points, values)
        o.writelines(str(o_data))


if __name__ == '__main__':
    timeit(main)
예제 #11
0
파일: failure.py 프로젝트: Almad/twisted
            failure.Failure()

def fail_str(n):
    for i in R:
        try:
            eval('deepFailure%d_0' % n)()
        except:
            str(failure.Failure())

class PythonException(Exception): pass

def fail_easy(n):
    for i in R:
        try:
            failure.Failure(PythonException())
        except:
            pass

from timer import timeit
# for i in O:
#     timeit(fail, 1, i)

# for i in O:
#     print 'easy failing', i, timeit(fail_easy, 1, i)

for i in O:
    print 'failing', i, timeit(fail, 1, i)

# for i in O:
#     print 'string failing', i, timeit(fail_str, 1, i)
예제 #12
0

def sloppify(n):
    """ Removes the ones place from the integer provided. """
    return int(n / 10) * 10


def main():
    import sys, time
    try:
        input_filename, output_filename = sys.argv[1:3]
    except ValueError:
        print('Usage: python sanitizer.py <input_file>, <output_file>')
    with open(input_filename) as f, open(output_filename, 'w') as o:
        data = []
        # Ignore first line
        first_line = f.readline()
        for line in f:
            t, x, y, z = line.split(',')
            data.append((int(t), int(x), int(y), int(z)))
        o_data = sanitize(data)
        o_data = [
            ','.join([str(t), str(x), str(y), str(z)]) for t, x, y, z in o_data
        ]
        o.write(first_line)
        o.writelines('\n'.join(o_data))


if __name__ == '__main__':
    timeit(main)
예제 #13
0
            eval("deepFailure%d_0" % n)()
        except:
            str(failure.Failure())


class PythonException(Exception):
    pass


def fail_easy(n):
    for i in R:
        try:
            failure.Failure(PythonException())
        except:
            pass


from timer import timeit

# for i in O:
#     timeit(fail, 1, i)

# for i in O:
#     print('easy failing', i, timeit(fail_easy, 1, i))

for i in O:
    print("failing", i, timeit(fail, 1, i))

# for i in O:
#     print('string failing', i, timeit(fail_str, 1, i))
예제 #14
0
#!/usr/bin/python
from __future__ import print_function

from timer import timeit
from twisted.spread.banana import b1282int

ITERATIONS = 100000

for length in (1, 5, 10, 50, 100):
    elapsed = timeit(b1282int, ITERATIONS, "\xff" * length)
    print("b1282int %3d byte string: %10d cps" % (length, ITERATIONS / elapsed))
예제 #15
0
파일: parser.py 프로젝트: T0aD/pyawstats
except Exception as e:
    die(e)

import apparser
parser = apparser.apparser()

# ##
import geoip
geoip = geoip.geoip('geoip.sqlite')
countries = {}
ips2countries = {}
useragents = {}
##

lineTimer = timer.timer()
sTimer = timer.timeit()
first = True
shit = []
weekday_cache = {}
updates = 0
inserts = 0
exceptions = 0
i = 0
for line in fd:
    if (i % 10001) == 0 and not i == 0:
        lineTimer.stop('parsed %10d lines' % i, i)
#    if i > passes:
#        break
    i += 1 # heresy!

    if gzipped is True:
예제 #16
0
def main():
    print("LoopingCall large advance takes", timeit(test_performance, iter=1))