Пример #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

        '''
Пример #4
0
 def clear_xpath_cache(my):
     my.cache_xpath = {}
     Container.put("XML:xpath_cache", {})
Пример #5
0
 def start_timer(my, name="top"):
     from container import Container
     if not Container.has("Base:total:%s" % name):
         Container.put("Base:total:%s" % name, 0)
     start = time.time()
     Container.put("Base:start:%s" % name, start)
Пример #6
0
 def start_timer(self, name="top"):
     from container import Container
     if not Container.has("Base:total:%s" % name):
         Container.put("Base:total:%s" % name, 0)
     start = time.time()
     Container.put("Base:start:%s" % name, start)
Пример #7
0
 def clear_xpath_cache(self):
     self.cache_xpath = {}
     Container.put("XML:xpath_cache", {})