示例#1
0
        def test_2(self):
            print('''
            ******************************
            *           test2            *
            ******************************
            ''')

            def foo():
                return random.random()

            def long():
                print('long called')
                time.sleep(.1)
                return 5

            rand = t.Timer(foo, interval=0, repeat=5)
            five = t.Timer(long, interval=0, repeat=5)
            one = t.Timer(1, interval=0, repeat=5)
            five2 = t.Timer(5, interval=0, repeat=5)

            neg_rand = t.Negate(t.Share(rand))

            x1 = t.Add(rand, five)  # 5 + rand
            x2 = t.Sub(x1, five2)  # rand
            x3 = t.Add(x2, neg_rand)  # 0
            res2 = t.Add(x3, one)  # 1
            p2 = t.Print(res2)  # 1

            t.PPrint(p2)
            t.run(p2)
示例#2
0
        def test_1(self):
            def foo():
                return random.random()

            print('''
            ******************************
            *           test             *
            ******************************
            ''')
            test = t.Timer(foo, {}, 0, 5)
            test2 = t.Negate(t.Share(test))
            res2 = t.Add(test, test2)
            p2 = t.Print(res2)
            t.run(p2)