def setUp(self): self.index = tempfile.mkdtemp() iconn = xappy.IndexerConnection(self.index) self.count = 100 self.weights = numpy.array( [x/float(self.count) for x in xrange(self.count, 0 ,-1)], 'float32') for w in self.weights: iconn.add(xappy.UnprocessedDocument()) self.weights.tofile(os.path.join(self.index, "weights.dat")) iconn.close() self.sconn = xappy.SearchConnection(self.index) self.query = dws.make_page_rank_query(self.sconn, self.source_type())
def do_time(index, st, res_count, warm = False): setup_string = """ import dws import xappy conn = xappy.SearchConnection('%s') st = %d """ % (index, st) if warm: setup_string = setup_string + """\ dws.make_page_rank_query(conn, %d) """ % st execute_string = """ query = dws.make_page_rank_query(conn, st) res = conn.search(query, 0, %d) list(res) """ % res_count timer = timeit.Timer(execute_string, setup_string) try: time = timer.timeit(10) print st, warm, time, res_count except: timer.print_exc()