From c8489fbc904f354bb009af65b4a1c42dc27cc132 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E4=BA=91=E5=B8=86?= <10195501416@stu.ecnu.edu.cn> Date: Mon, 13 Dec 2021 13:22:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E8=B4=9F=E8=BD=BD=E7=94=9F?= =?UTF-8?q?=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fe/bench/workload.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/fe/bench/workload.py b/fe/bench/workload.py index d7c9e6e..ff89430 100644 --- a/fe/bench/workload.py +++ b/fe/bench/workload.py @@ -33,7 +33,7 @@ class Payment: class Workload: def __init__(self): self.uuid = str(uuid.uuid1()) - self.book_ids = [] + self.book_ids = {} self.buyer_ids = [] self.store_ids = [] self.book_db = book.BookDB(conf.Use_Large_DB) @@ -92,8 +92,7 @@ class Workload: for bk in books: code = seller.add_book(store_id, self.stock_level, bk) assert code == 200 - if i == 1 and j == 1: - self.book_ids.append(bk.id) + self.book_ids[store_ids].append(bk.id) row_no = row_no + len(books) logging.info("seller data loaded.") for k in range(1, self.buyer_num + 1): @@ -112,8 +111,8 @@ class Workload: book_id_and_count = [] book_temp = [] for i in range(0, books): - book_no = int(random.uniform(0, len(self.book_ids) - 1)) - book_id = self.book_ids[book_no] + book_no = int(random.uniform(0, len(self.book_ids[store_id]) - 1)) + book_id = self.book_ids[store_id][book_no] if book_id in book_temp: continue else: