def cache_accounts(cls, accounts):
from hive.indexer.cache import batch_queries
processed = 0
total = len(accounts)
for i in range(0, total, 1000):
batch = accounts[i:i+1000]
lap_0 = time.perf_counter()
sqls = cls._generate_cache_sqls(batch)
lap_1 = time.perf_counter()
batch_queries(sqls)
lap_2 = time.perf_counter()
if len(batch) < 1000:
continue
processed += len(batch)
rem = total - processed
rate = len(batch) / (lap_2 - lap_0)
pct_db = int(100 * (lap_2 - lap_1) / (lap_2 - lap_0))
print(" -- account {} of {} ({}/s, {}% db) -- {}m remaining".format(
processed, total, round(rate, 1), pct_db, round(rem / rate / 60, 2)))
评论列表
文章目录