Esempio n. 1
0
 def test_threadDataDictionaryDurationOfThreadsIsLessThan2Sec(self):
     dictThread = {}
     gd = GatherData()
     td = ThreadingData()
     start = time.perf_counter()
     t1 = td.createThread(
         function=dictThread.update({"thread1": gd.getDataSource1}))
     t2 = td.createThread(
         function=dictThread.update({"thread2": gd.getDataSource2}))
     td.startThread(t1)
     td.startThread(t2)
     td.joinThread(t1)
     td.joinThread(t2)
     finish = time.perf_counter()
     print(dictThread.get("thread1")())
     self.assertTrue(finish - start < 2)
Esempio n. 2
0
    def test_threadDataDictionaryGetThread4DurationIsLessThan2Sec(self):
        dictThread = {}
        gd = GatherData()
        td = ThreadingData()
        start = time.perf_counter()
        t1 = td.createThread(
            function=dictThread.update({"thread1": gd.getDataSource1}))
        t2 = td.createThread(
            function=dictThread.update({"thread2": gd.getDataSource2}))
        t3 = td.createThread(
            function=dictThread.update({"thread3": gd.getDataSource3}))
        t4 = td.createThread(
            function=dictThread.update({"thread4": gd.getDataSource4}))
        threadList = [t1, t2, t3, t4]

        for thread in threadList:
            td.startThread(thread)

        for thread in threadList:
            td.joinThread(thread)

        finish = time.perf_counter()
        print(dictThread.get("thread4")())
        self.assertTrue(finish - start < 2)
Esempio n. 3
0
 def test_threadDataQueGetThread2DurationOfThreadsIsLessThan2Sec(self):
     que = queue.Queue()
     gd = GatherData()
     td = ThreadingData()
     start = time.perf_counter()
     t1 = td.createThread(function=que.put(gd.getDataSource1))
     t2 = td.createThread(function=que.put(gd.getDataSource2))
     td.startThread(t1)
     td.startThread(t2)
     td.joinThread(t1)
     td.joinThread(t2)
     finish = time.perf_counter()
     que.get()()
     print(que.get()())
     self.assertTrue(finish - start < 2)
Esempio n. 4
0
    def test_ThreadDictionaryGetThreads15DurationIsMoreThan3Sec(self):
        dictThread = {}
        gd = GatherData()
        td = ThreadingData()
        start = time.perf_counter()
        t1 = td.createThread(
            function=dictThread.update({"thread1": gd.getDataSource1}))
        t2 = td.createThread(function=dictThread.update(
            {"thread2": gd.getDataSource5}),
                             arguments=[2])
        threadList = [t1, t2]
        for thread in threadList:
            td.startThread(thread)
        for thread in threadList:
            td.joinThread(thread)

        finish = time.perf_counter()

        self.assertTrue(finish - start < 3)
Esempio n. 5
0
 def test_durationOfThreadsIsLessThan3Sec(self):
     start = time.perf_counter()
     gd = GatherData()
     td = ThreadingData()
     # when it comes to using the function in thread. No Parenthesis
     thread = td.createThread(function=gd.getDataSource1)
     thread2 = td.createThread(function=gd.getDataSource3)
     td.startThread(thread)
     td.startThread(thread2)
     threadList = []
     threadList.append(thread)
     threadList.append(thread2)
     td.joinThread(thread)
     td.joinThread(thread2)
     finish = time.perf_counter()
     self.assertTrue(finish - start < 3)