提交 6f3d5799 authored 作者: Frederic's avatar Frederic

More timmig with 2 threads

上级 7b7c54c3
...@@ -106,6 +106,7 @@ def main(dev1, dev2): ...@@ -106,6 +106,7 @@ def main(dev1, dev2):
r = self.f() r = self.f()
if self.sync: if self.sync:
r[0].sync() r[0].sync()
self.r = r
# print "Exiting " + self.name # print "Exiting " + self.name
thread1 = myThread("Thread-1", f3, True) thread1 = myThread("Thread-1", f3, True)
...@@ -119,6 +120,30 @@ def main(dev1, dev2): ...@@ -119,6 +120,30 @@ def main(dev1, dev2):
print("two ctx, 2 fct async, 2 threads %f" % (t2 - t,)) print("two ctx, 2 fct async, 2 threads %f" % (t2 - t,))
thread1 = myThread("Thread-1", f3, True)
thread2 = myThread("Thread-2", f4, True)
t = time.time()
thread1.start()
thread2.start()
thread2.join()
thread1.join()
t2 = time.time()
print("two ctx, 2 fct async, 2 threads %f reverse join" % (t2 - t,))
thread1 = myThread("Thread-1", f3, False)
thread2 = myThread("Thread-2", f4, False)
t = time.time()
thread1.start()
thread2.start()
thread1.join()
thread2.join()
thread1.r[0].sync()
thread2.r[0].sync()
t2 = time.time()
print("two ctx, 2 fct async + late sync, 2 threads %f" % (t2 - t,))
thread1 = myThread("Thread-3", f5, False) thread1 = myThread("Thread-3", f5, False)
thread2 = myThread("Thread-4", f6, False) thread2 = myThread("Thread-4", f6, False)
t = time.time() t = time.time()
...@@ -130,6 +155,17 @@ def main(dev1, dev2): ...@@ -130,6 +155,17 @@ def main(dev1, dev2):
print("two ctx, 2 fct with transfer, 2 threads %f" % (t2 - t,)) print("two ctx, 2 fct with transfer, 2 threads %f" % (t2 - t,))
thread1 = myThread("Thread-3", f5, False)
thread2 = myThread("Thread-4", f6, False)
t = time.time()
thread1.start()
thread2.start()
thread2.join()
thread1.join()
t2 = time.time()
print("two ctx, 2 fct with transfer, 2 threads %f reverse join" % (t2 - t,))
if __name__ == '__main__': if __name__ == '__main__':
import sys import sys
if len(sys.argv) != 3: if len(sys.argv) != 3:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论