from python_libs.browser_proxy import BrowserProxy from python_libs.bandwidth_manipulator import BandwidthManipulator class Configuration: def __init__(self): self.capture_duration = 100 self.increase_throughput_step_size = 60 self.start_throughput = 800 self.stop_throughput = 2000 self.wait_after_page_load = 60 self.wait_after_throughput_adjustment = 60 static_config = StaticConfig() video_ids = Inventory().full_capture() # define the ids we want to capture config = Configuration() # calculate length of capture for user loop_count = (config.stop_throughput - config.start_throughput) / config.increase_throughput_step_size video_count = len(video_ids) loop_length = config.capture_duration + config.wait_after_throughput_adjustment full_length = video_count * (config.wait_after_page_load + loop_count * loop_length) print("this capture will run for " + humanfriendly.format_timespan(full_length)) # initialize the bandwidth
import matplotlib.pyplot as plt import sqlite3 from python_libs.config import StaticConfig, Inventory config = StaticConfig() inventory = Inventory() # get sqlite connection db_file_name = config.captures_dir + "/data.sqlite" connection = sqlite3.connect(db_file_name) cursor = connection.cursor() cursor.execute("SELECT DISTINCT movie_id, bitrate FROM captures ORDER BY movie_id") db_movies = cursor.fetchall() total_body_sizes = {} movie_counter = 0 last_movie_id = 0 x = [] y = [] sql = [] for db_movie in db_movies: movie_id = db_movie[0] if movie_id != last_movie_id: if last_movie_id != 0: cursor.execute(" INTERSECT ".join(sql)) db_movies = cursor.fetchall() assert(len(db_movies) > 0) if len(db_movies) > 1: print("found bitrate collision for " + str(last_movie_id))
# plots the average bandwidth used at specific points in time; else its 0 import matplotlib.pyplot as plt import sqlite3 import dateutil import time from python_libs.config import StaticConfig, Inventory RESOLUTION = 10 config = StaticConfig() inventory = Inventory() normalize_cache = None normalize_cache_result = None def get_adapted_time(current_point, normalize_point): global normalize_cache_result, normalize_cache if normalize_point is not normalize_cache: normalize_cache_result = convert_to_integer(normalize_point) normalize_cache = normalize_point return convert_to_integer(current_point) - normalize_cache_result def convert_to_integer(date): my_date = dateutil.parser.parse(date) return int(time.mktime(my_date.timetuple()) * 1000 + my_date.microsecond / 1000)