mirror of
https://gitee.com/milvus-io/milvus.git
synced 2026-01-07 19:31:51 +08:00
[skip e2e]Unified time output format (#14638)
Signed-off-by: zhuwenxing <wenxing.zhu@zilliz.com>
This commit is contained in:
parent
4fe0e5e457
commit
0da1b04c4c
@ -54,13 +54,13 @@ def hello_milvus(host="127.0.0.1"):
|
||||
]
|
||||
)
|
||||
t1 = time.time()
|
||||
print(f"\nInsert {nb} vectors cost {t1 - t0} seconds")
|
||||
print(f"\nInsert {nb} vectors cost {t1 - t0:.4f} seconds")
|
||||
|
||||
t0 = time.time()
|
||||
print(f"\nGet collection entities...")
|
||||
print(collection.num_entities)
|
||||
t1 = time.time()
|
||||
print(f"\nGet collection entities cost {t1 - t0} seconds")
|
||||
print(f"\nGet collection entities cost {t1 - t0:.4f} seconds")
|
||||
|
||||
# create index and load table
|
||||
default_index = {"index_type": "IVF_FLAT", "params": {"nlist": 128}, "metric_type": "L2"}
|
||||
@ -68,31 +68,31 @@ def hello_milvus(host="127.0.0.1"):
|
||||
t0 = time.time()
|
||||
collection.create_index(field_name="float_vector", index_params=default_index)
|
||||
t1 = time.time()
|
||||
print(f"\nCreate index cost {t1 - t0} seconds")
|
||||
print(f"\nCreate index cost {t1 - t0:.4f} seconds")
|
||||
print(f"\nload collection...")
|
||||
t0 = time.time()
|
||||
collection.load()
|
||||
t1 = time.time()
|
||||
print(f"\nload collection cost {t1 - t0} seconds")
|
||||
print(f"\nload collection cost {t1 - t0:.4f} seconds")
|
||||
|
||||
# load and search
|
||||
topK = 5
|
||||
search_params = {"metric_type": "L2", "params": {"nprobe": 10}}
|
||||
start_time = time.time()
|
||||
t0 = time.time()
|
||||
print(f"\nSearch...")
|
||||
# define output_fields of search result
|
||||
res = collection.search(
|
||||
vectors[-2:], "float_vector", search_params, topK,
|
||||
"count > 100", output_fields=["count", "random_value"], timeout=TIMEOUT
|
||||
)
|
||||
end_time = time.time()
|
||||
|
||||
t1 = time.time()
|
||||
print(f"search cost {t1 - t0:.4f} seconds")
|
||||
# show result
|
||||
for hits in res:
|
||||
for hit in hits:
|
||||
# Get value of the random value field for search result
|
||||
print(hit, hit.entity.get("random_value"))
|
||||
print("search latency = %.4fs" % (end_time - start_time))
|
||||
|
||||
|
||||
# query
|
||||
expr = "count in [2,4,6,8]"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user