Пример #1
0
    def end_timer(my, name="top"):
        end = time.time()
        from container import Container
        start = Container.get("Base:start:%s" % name)
        diff = end - start
        total = Container.get("Base:total:%s" % name)
        total += diff
        Container.put("Base:total:%s" % name, total)

        Base.__timing += diff
        return total
Пример #2
0
    def end_timer(self, name="top"):
        end = time.time()
        from container import Container
        start = Container.get("Base:start:%s" % name)
        diff = end - start
        total = Container.get("Base:total:%s" % name)
        total += diff
        Container.put("Base:total:%s" % name, total)

        Base.__timing += diff
        return total
Пример #3
0
    def _evaluate(my, xpath):
        cache = Container.get("XML:xpath_cache")
        if cache == None:
            cache = {}
            Container.put("XML:xpath_cache", cache)

        #key = "%s|%s" % (str(my.doc), xpath)
        num = random.randint(0, 500000)
        key = "%s_%s|%s" % (str(my.doc), num, xpath)
        result = cache.get(key)
        if result == None:
            result = Evaluate(xpath, my.doc)
            cache[key] = result
            #print xpath
        else:
            #print "reuse"
            pass

        return result

        '''