def _GenerateStaleWhileRevalidateBenchmarkTasks(common_builder, main_transformer, benchmark_setup): # Compile domain regexes. domain_regexes = [] for e in benchmark_setup['domain_regexes']: domain_regexes.append({ 'usage': e['usage'], 'domain_regex': re.compile(e['domain_regex']) }) # Build tasks. builder = sandwich_swr.StaleWhileRevalidateBenchmarkBuilder(common_builder) for network_condition in benchmark_setup['network_conditions']: transformer_list_name = network_condition.lower() network_transformer = \ sandwich_utils.NetworkSimulationTransformer(network_condition) transformer_list = [main_transformer, network_transformer] builder.PopulateBenchmark('no-swr', [], transformer_list_name, transformer_list) for usage_threshold in benchmark_setup['usage_thresholds']: benchmark_name = 'threshold{}'.format(usage_threshold) selected_domain_regexes = [ e['domain_regex'] for e in domain_regexes if e['usage'] > usage_threshold ] builder.PopulateBenchmark(benchmark_name, selected_domain_regexes, transformer_list_name, transformer_list)
def _GenerateStaleWhileRevalidateBenchmarkTasks(common_builder, main_transformer, benchmark_setup): builder = sandwich_swr.StaleWhileRevalidateBenchmarkBuilder(common_builder) for enable_swr in [False, True]: builder.PopulateBenchmark(enable_swr, _MAIN_TRANSFORMER_LIST_NAME, transformer_list=[main_transformer]) for network_condition in benchmark_setup['network_conditions']: transformer_list_name = network_condition.lower() network_transformer = \ sandwich_utils.NetworkSimulationTransformer(network_condition) transformer_list = [main_transformer, network_transformer] builder.PopulateBenchmark(enable_swr, transformer_list_name, transformer_list)
def _GenerateNoStatePrefetchBenchmarkTasks(common_builder, main_transformer, benchmark_setup): builder = sandwich_prefetch.PrefetchBenchmarkBuilder(common_builder) builder.PopulateLoadBenchmark(sandwich_prefetch.Discoverer.EmptyCache, _MAIN_TRANSFORMER_LIST_NAME, transformer_list=[main_transformer]) builder.PopulateLoadBenchmark(sandwich_prefetch.Discoverer.FullCache, _MAIN_TRANSFORMER_LIST_NAME, transformer_list=[main_transformer]) for network_condition in benchmark_setup['network_conditions']: transformer_list_name = network_condition.lower() network_transformer = \ sandwich_utils.NetworkSimulationTransformer(network_condition) transformer_list = [main_transformer, network_transformer] for subresource_discoverer in benchmark_setup[ 'subresource_discoverers']: builder.PopulateLoadBenchmark(subresource_discoverer, transformer_list_name, transformer_list)