Exemple #1
0
    def analyze(self, program_file_path: str, config: Config) -> None:
        """
        Runs e2e analyses on the given program
        :param program_file_path: **absolute** path to the program to analyze
        :param config: config object for user-defined configuration
        """
        input_sizes: List[int] = config.get_input_sizes()

        # creates all required dockerfiles and stores paths in a dict of <input_size, dockerfile path>
        debug("Creating dockerfiles for each input size")
        dockerfiles: Dict[int, str] = \
            {size: self._build_dockerfile_for_input(program_file_path, size, config) for size in input_sizes}

        # builds all the dockerfiles into images and stores the image names in a dict of <input_size, image name>
        debug("Building docker images for each input size")
        images: Dict[int, str] = \
            {size: build_docker_image(dockerfile) for size, dockerfile in dockerfiles.items()}

        # execute the test runs
        for input_size, image in images.items():
            debug("Analyzing for input size {}".format(input_size))
            individual_results: List[TestResult] = self._run_test_container(
                image, self.RUNS_PER_INPUT_SIZE)
            computed_results: InputSizeResult = self._compute_average(
                individual_results)
            self.results[input_size] = computed_results

        debug("End-to-end analysis complete!")
        debug("Doing some clean-up!")
        try:
            delete_all_docker_images(exceptions=["python"], force=True)
            debug("All cleaned-up here.")
        except:
            debug("Cleanup failed. Please cleanup Docker manually")
Exemple #2
0
def test_sample_config_complete():
    config_path = path.join(PATH_TO_SAMPLE_CONFIGS,
                            "sample_config_complete.json")
    config = Config(config_path)
    assert config.get_input_sizes() == [1, 2, 10, 20, 30, 100, 2000]
    assert config.get_args_for(1) == ["-n", "51", "-f", "/some/file"]
    assert config.get_args_for(2) == ["-n", "52", "-f", "/some/file"]
    assert config.get_args_for(10) == ["-n", "60", "-f", "/some/file"]
    assert config.get_args_for(20) == ["-n", "70", "-f", "/some/file"]
    assert config.get_args_for(30) == ["-n", "80", "-f", "/some/file"]
    assert config.get_args_for(100) == ["-n", "150", "-f", "/some/file"]
    assert config.get_args_for(2000) == ["-n", "2050", "-f", "/some/file"]