forked from codefuse-ai/ModelCache
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathreport.py
More file actions
44 lines (37 loc) · 1.12 KB
/
report.py
File metadata and controls
44 lines (37 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# -*- coding: utf-8 -*-
class Report:
def __init__(self):
self.embedding_all_time = 0
self.embedding_count = 0
self.search_all_time = 0
self.search_count = 0
self.hint_cache_count = 0
def embedding(self, delta_time):
"""Embedding counts and time.
:param delta_time: additional runtime.
"""
self.embedding_all_time += delta_time
self.embedding_count += 1
def search(self, delta_time):
"""Search counts and time.
:param delta_time: additional runtime.
"""
self.search_all_time += delta_time
self.search_count += 1
def average_embedding_time(self):
"""Average embedding time."""
return round(
self.embedding_all_time / self.embedding_count
if self.embedding_count != 0
else 0,
4,
)
def average_search_time(self):
return round(
self.search_all_time / self.search_count
if self.embedding_count != 0
else 0,
4,
)
def hint_cache(self):
self.hint_cache_count += 1