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
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
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 '''
def clear_xpath_cache(my): my.cache_xpath = {} Container.put("XML:xpath_cache", {})
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)
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)
def clear_xpath_cache(self): self.cache_xpath = {} Container.put("XML:xpath_cache", {})