Cache result file to speed up generation of website.
@@ -4,6 +4,9 @@ from ann_benchmarks.plotting.metrics import all_metrics as metrics
import matplotlib.pyplot as plt
import numpy
+results_cache = {}
+results_call_set = {}
+
def create_pointset(algo, all_data, xm, ym):
data = all_data[algo]
rev = ym["worst"] < 0
@@ -31,6 +34,10 @@ def enumerate_query_caches(ds):
yield "queries/" + f
def load_results(datasets, xm, ym, limit = -1):
+ ds_id = "".join(datasets) + xm["description"] + ym["description"] + str(limit)
+ if ds_id in results_call_set:
+ return results_call_set[ds_id]
+
runs = {}
all_algos = set()
for ds in datasets:
@@ -46,9 +53,17 @@ first (%s)""" % (ds, queries_fn[0])
queries = pickle.load(open(queries_fn))
runs[ds] = {}
+ if not ds in results_cache:
with open(get_fn("results", ds, limit)) as f:
+ results_cache[ds] = []
for line in f:
- run = json.loads(line)
+ try:
+ l = json.loads(line)
+ except:
+ print "Skipping line"
+ results_cache[ds].append(l)
+
+ for run in results_cache[ds]:
algo = run["library"]
algo_name = run["name"]
build_time = run["build_time"]
@@ -66,6 +81,7 @@ first (%s)""" % (ds, queries_fn[0])
if not algo in runs[ds]:
runs[ds][algo] = []
runs[ds][algo].append((algo, algo_name, xv, yv))
+ results_call_set[ds_id] = (runs, all_algos)
return (runs, all_algos)
def create_linestyles(algos):
