Esempio n. 1
0
    def _createtimers(self):
        timers_count = 1000000

        import time
        beg_add_time = time.time()
        print 'add {} timers:'.format(timers_count)

        random = llbc.Random()
        for i in range(0, timers_count):
            timer = llbc.Timer(self.ontimeout, self.oncancel)
            timer.schedule(random.rand(5000, 15000), random.rand(5000, 15000))

        cost_time = (time.time() - beg_add_time) * 1000
        print 'done, cost time(ms):{}'.format(cost_time)
Esempio n. 2
0
 def _createtimers(self):
     random = llbc.Random()
     for i in range(0, 500000):
         timer = llbc.Timer(self.ontimeout, self.oncancel)
         timer.schedule(random.rand(5000, 15000), random.rand(5000, 15000))
Esempio n. 3
0
        return llbc.inl.BoolJudge(self.__c_obj)

    def choice(self, seq):
        """
        Random choose one element at given sequence object(tuple, list, str, or unicode type instance).
        :return: the choiced element.
        """
        if not seq:
            return None

        return seq[self.rand(seq.__len__())]


llbc.Random = pyllbcRandom

__gbl_random = llbc.Random()


def pyllbcSeedRand(seed):
    __gbl_random.seed(seed)


llbc.seedrand = pyllbcSeedRand


def pyllbcRandInt(begin=None, end=None):
    return __gbl_random.rand(begin, end)


llbc.randint = pyllbcRandInt