|
@@ -16,19 +16,19 @@ redis_helper = RedisHelper()
|
|
|
|
|
|
def thompson_process(creative_id):
|
|
|
# 获取creative_id对应的Thompson参数
|
|
|
- st_time1 = time.time()
|
|
|
+ # st_time1 = time.time()
|
|
|
thompson_param = redis_helper.get_data_from_redis(key_name=f"{config_.THOMPSON_PARAM_KEY_PREFIX}{creative_id}")
|
|
|
- get_redis_time = int(time.time() - st_time1) * 1000
|
|
|
+ # get_redis_time = int(time.time() - st_time1) * 1000
|
|
|
thompson_time = {}
|
|
|
if thompson_param is None or thompson_param == '':
|
|
|
# 参数不存在,随机生成[0, 1)之间的浮点数
|
|
|
st_time2 = time.time()
|
|
|
score = random.random()
|
|
|
- thompson_time['random'] = int(time.time() - st_time2) * 1000
|
|
|
+ # thompson_time['random'] = int(time.time() - st_time2) * 1000
|
|
|
random_flag = 'random'
|
|
|
else:
|
|
|
# 参数存在
|
|
|
- st_time3 = time.time()
|
|
|
+ # st_time3 = time.time()
|
|
|
param_alpha, param_beta = json.loads(thompson_param.strip())
|
|
|
param_alpha, param_beta = int(param_alpha), int(param_beta)
|
|
|
if param_alpha + param_beta >= 100:
|
|
@@ -39,9 +39,9 @@ def thompson_process(creative_id):
|
|
|
# ad_idea_id 曝光数 < 100,随机生成[0, 1)之间的浮点数
|
|
|
score = random.random()
|
|
|
random_flag = 'random'
|
|
|
- thompson_time['beta'] = int(time.time() - st_time3) * 1000
|
|
|
+ # thompson_time['beta'] = int(time.time() - st_time3) * 1000
|
|
|
thompson_res = [creative_id, score, thompson_param, random_flag]
|
|
|
- log_.info(f"get_redis_time: {get_redis_time}, thompson_time: {thompson_time}")
|
|
|
+ # log_.info(f"get_redis_time: {get_redis_time}, thompson_time: {thompson_time}")
|
|
|
return thompson_res
|
|
|
|
|
|
|
|
@@ -68,6 +68,6 @@ def get_creative_id_with_thompson(mid, creative_id_list):
|
|
|
'random_flag': thompson_res_rank[0][3],
|
|
|
'thompson_res_rank': thompson_res_rank
|
|
|
}
|
|
|
- log_.info(f"gevent_pool_time: {gevent_pool_time}, get_random_time: {get_random_time}, sort_time: {sort_time}")
|
|
|
+ log_.info({'gevent_pool_time': gevent_pool_time, 'get_random_time': get_random_time, 'sort_time': sort_time})
|
|
|
return rank_res
|
|
|
|