def process_expired(self): # read and process expired values expired_sessions = self.expiry_list.expired for session in expired_sessions: s = self.smap[session] if not self.valid_expired_session(session): del self.smap[session] continue expt_id = str(session[-1]) expt_config = retrieve_expt_config(expt_id, self.expt, self.postgres_cursor) abr_cc = get_abr_cc(expt_config) if abr_cc not in self.out: self.out[abr_cc] = {} self.out[abr_cc]['total_play'] = 0 self.out[abr_cc]['total_rebuf'] = 0 session_play = ((s['max_play_time'] - s['min_play_time']) / np.timedelta64(1, 's')) session_rebuf = s['max_cum_rebuf'] - s['min_cum_rebuf'] self.out[abr_cc]['total_play'] += session_play self.out[abr_cc]['total_rebuf'] += session_rebuf del self.smap[session] # clean processed expired values self.expiry_list.expired = []
def process_rebuffer_session(session, s): # exclude too short sessions if s['play_time'] < 5: return expt_id = str(session[-1]) expt_config = retrieve_expt_config(expt_id, expt, postgres_cursor) abr_cc = get_abr_cc(expt_config) global g_rebuffer if abr_cc not in g_rebuffer: g_rebuffer[abr_cc] = {} g_rebuffer[abr_cc]['total_play'] = 0 g_rebuffer[abr_cc]['total_rebuf'] = 0 g_rebuffer[abr_cc]['total_play'] += s['play_time'] g_rebuffer[abr_cc]['total_rebuf'] += s['cum_rebuf']
def calculate_rebuffer_by_abr_cc(d, expt_id_cache, postgres_cursor): x = {} # indexed by (abr, cc) for session in d: expt_id = int(session[-1]) expt_config = retrieve_expt_config(expt_id, expt_id_cache, postgres_cursor) abr_cc = get_abr_cc(expt_config) if abr_cc not in x: x[abr_cc] = {} x[abr_cc]['total_play'] = 0 x[abr_cc]['total_rebuf'] = 0 x[abr_cc]['total_play'] += d[session]['play'] x[abr_cc]['total_rebuf'] += d[session]['rebuf'] return x
def do_collect_ssim(s_str, e_str, d): sys.stderr.write('Processing video_acked data between {} and {}\n' .format(s_str, e_str)) video_acked_results = query_measurement( influx_client, 'video_acked', s_str, e_str)['video_acked'] for pt in video_acked_results: expt_id = str(pt['expt_id']) expt_config = retrieve_expt_config(expt_id, expt, postgres_cursor) abr_cc = get_abr_cc(expt_config) if abr_cc not in d: d[abr_cc] = [0.0, 0] # sum, count ssim_index = get_ssim_index(pt) if ssim_index is not None and ssim_index != 1: d[abr_cc][0] += ssim_index d[abr_cc][1] += 1
def do_collect_ssim(video_acked_results, expt_id_cache, postgres_cursor): # process InfluxDB data x = {} for pt in video_acked_results['video_acked']: expt_id = get_expt_id(pt) expt_config = retrieve_expt_config(expt_id, expt_id_cache, postgres_cursor) abr_cc = get_abr_cc(expt_config) if abr_cc not in x: x[abr_cc] = [] ssim_index = get_ssim_index(pt) if ssim_index is not None: x[abr_cc].append(ssim_index) # calculate average SSIM in dB for abr_cc in x: avg_ssim_index = np.mean(x[abr_cc]) avg_ssim_db = ssim_index_to_db(avg_ssim_index) x[abr_cc] = avg_ssim_db return x