Esempio n. 1
0
    def spamPub():
        threads = []
        m = prata.connect("127.0.0.1",25570)
        for index in range(SPAM):
            x = threading.Thread(target=sendPub, args=(m,))
            threads.append(x)
            x.start()

        for thread in threads:
            thread.join()
Esempio n. 2
0
    def spamChan():
        threads = []
        m = prata.connect("127.0.0.1",25574)
        tmp = str(randint(1,10000))
        m.publisher().connect(tmp)
        for index in range(SPAM):
            x = threading.Thread(target=sendChan, args=(m, tmp,))
            threads.append(x)
            x.start()

        for thread in threads:
            thread.join()
Esempio n. 3
0
        f.write("Average: {}s\n".format(stats[3]))
        f.write("Average {}/s: {}\n".format(bytes, mbs[3]))
        f.write("###################\n\n")
    else:
        END.append([kilo, stats[3]])
    f.close()


def getStats(times):
    return [np.min(times), np.median(times), np.max(times), np.average(times)]


f = open("pythonThrouput.txt", "w")
f.close()

m = prata.connect("127.0.0.1", 25565)
m.host()
m.createChannel(25566, "test", "FIFO", 500)

SIZE = (1 * B)
testListen = '''
p.publish("test",STRING)
t = s.listen("test")
'''
obj = getString(SIZE)
setupTestListen = """
STRING =  \"""" + obj + """\"
import prata
m = prata.connect(\"127.0.0.1\",25565)
s = m.subscriber()
p = m.publisher()
Esempio n. 4
0
import prata as tl
import time
import json
print("TEST: Testing for Statistics")
m = tl.connect("127.0.0.1", 25565)

m.host()
time.sleep(1)

sub = m.subscriber()
pub = m.publisher()

pub.publish("1", "message1")
pub.publish("1", "message2")

if ("message1" != sub.listen("1")):
    print("---TEST: failure in statistics listen uno")

if ("message2" != sub.listen("1")):
    print("---TEST: failure in statistics listen dos")

i = 0
while i < 501:
    pub.publish("2", str(i))
    i += 1

i = 1
while i < 300:
    tmp = sub.listen("2")
    if (str(i) != tmp):
        print("---TEST: failure in mass recieve", str(i), tmp)
Esempio n. 5
0
def closeDefault():
    m = prata.connect("127.0.0.1", 25565)
    m.terminate()
Esempio n. 6
0
m = prata.connect("127.0.0.1", 25566)
p = m.publisher()
p.connect("K")
'''

createChannel='''
s.listen(str(randint(1,10000)))
'''

print("Startup of network")

printStats(getStats(timeit.Timer(stmt=networkStartup,setup=networkStartupSetup).repeat(number=NUMBERS,repeat=(REPEATS))),"Startup of network")
time.sleep(TIMEBETWEEN)

print("Channel creation")
m = prata.connect("127.0.0.1", 25565)
m.host()
printStats(getStats(timeit.Timer(stmt=createChannel,setup="import prata; from random import randint; m = prata.connect('127.0.0.1', 25565);s=m.subscriber()").repeat(number=NUMBERS,repeat=(REPEATS))),"Channel creation")
m.terminate()
time.sleep(TIMEBETWEEN)

print("Listen function call time without known channel")
m = prata.connect("127.0.0.1", 25566)
m.host()
printStats(getStats( timeit.Timer(stmt='s.listen("NK")', setup=setupListenNK).repeat(number=NUMBERS,repeat=REPEATS)),"Listen function call time without known channel")
time.sleep(TIMEBETWEEN)

print("Listen function call time with known channel")
printStats(getStats(timeit.Timer(stmt='s.listen("K")', setup=setupListenK).repeat(number=NUMBERS,repeat=REPEATS)),"Listen function call time with known channel")
time.sleep(TIMEBETWEEN)