From 93eb65262dd0ef63f929be8373bf451c9029ab01 Mon Sep 17 00:00:00 2001 From: Denis Date: Sat, 7 Dec 2019 13:06:40 +0300 Subject: [PATCH] Remove old performance tests as unused ones --- tests_perf/README.md | 49 ---- tests_perf/__init__.py | 27 --- tests_perf/asv.conf.json | 192 ---------------- tests_perf/asv_hpat_plugin.py | 109 --------- tests_perf/asvgen.py | 122 ---------- tests_perf/benchmark.py | 137 ------------ tests_perf/build_hpat.py | 174 --------------- tests_perf/runner.py | 219 ------------------ tests_perf/templates/asvgen.html | 54 ----- tests_perf/tests/__init__.py | 27 --- tests_perf/tests/algorithms.py | 333 ---------------------------- tests_perf/tests/common.py | 53 ----- tests_perf/tests/data_generator.py | 187 ---------------- tests_perf/tests/io/__init__.py | 27 --- tests_perf/tests/io/csv.py | 56 ----- tests_perf/tests/series.py | 219 ------------------ tests_perf/tests/unicode_strings.py | 82 ------- 17 files changed, 2067 deletions(-) delete mode 100644 tests_perf/README.md delete mode 100644 tests_perf/__init__.py delete mode 100644 tests_perf/asv.conf.json delete mode 100644 tests_perf/asv_hpat_plugin.py delete mode 100644 tests_perf/asvgen.py delete mode 100644 tests_perf/benchmark.py delete mode 100644 tests_perf/build_hpat.py delete mode 100644 tests_perf/runner.py delete mode 100644 tests_perf/templates/asvgen.html delete mode 100644 tests_perf/tests/__init__.py delete mode 100644 tests_perf/tests/algorithms.py delete mode 100644 tests_perf/tests/common.py delete mode 100644 tests_perf/tests/data_generator.py delete mode 100644 tests_perf/tests/io/__init__.py delete mode 100644 tests_perf/tests/io/csv.py delete mode 100644 tests_perf/tests/series.py delete mode 100644 tests_perf/tests/unicode_strings.py diff --git a/tests_perf/README.md b/tests_perf/README.md deleted file mode 100644 index 22327b09c..000000000 --- a/tests_perf/README.md +++ /dev/null @@ -1,49 +0,0 @@ -# HPAT Performance Tests -There are 2 ways to run performance testing. -The first one is via the custom runner `runner.py`. The second one is through ASV. - -## 1. Custom run -#### Preparing: -1. Manually create Conda environment with installed required packages for HPAT, -activate the environment -2. Install `jinja2` for report generating: `conda install jinja2` -3. Build HPAT via `build_hpat.py` or manually:
-`python build_hpat.py --env-dir --build-dir ` - -#### Running -`python runner.py` - -#### Report generating -`python asvgen.py --asv-results ../build/tests_perf --template templates/asvgen.html` - -## 2. ASV run -#### Pipeline: -Provided by `asv.conf.json` file. -1. Create Conda environment with defined dependencies -2. Pull HPAT source code -3. Uninstall previous HPAT build -4. Build HPAT from source -5. Install HPAT -7. Run performance tests - - -#### Running -##### Deactivate HPAT. Activate environment base. -##### Install Airspeed Velocity in Anaconda Prompt: -`conda install -c conda-forge asv` - -##### Run tests: -`cd /tests_perf`
-`asv run`
-Extra useful flags:
-`--quick` is used to run each test case only once and prevent saving of results
-`--show-stderr` is used to display the stderr output from the tests - -##### View results: -1. Console mode: - 1. Show tested commits: `asv show`
- 2. Show tests results for a commit: `asv show `
-2. Browser mode: - 1. Collect all results into a website: `asv publish`
- 2. Preview results using a local web server: `asv preview`
- 2. Open `http://:` in a browser, e.g. `http://127.0.0.1:8080` \ No newline at end of file diff --git a/tests_perf/__init__.py b/tests_perf/__init__.py deleted file mode 100644 index d15aaf47d..000000000 --- a/tests_perf/__init__.py +++ /dev/null @@ -1,27 +0,0 @@ -# ***************************************************************************** -# Copyright (c) 2019, Intel Corporation All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ***************************************************************************** - - diff --git a/tests_perf/asv.conf.json b/tests_perf/asv.conf.json deleted file mode 100644 index 37f0384d0..000000000 --- a/tests_perf/asv.conf.json +++ /dev/null @@ -1,192 +0,0 @@ -{ - // The version of the config file format. Do not change, unless - // you know what you are doing. - "version": 1, - - // The name of the project being benchmarked - "project": "hpat", - - // The project's homepage - "project_url": "", - - // The URL or local path of the source code repository for the - // project being benchmarked - "repo": "..", - - // The Python project's subdirectory in your repo. If missing or - // the empty string, the project is assumed to be located at the root - // of the repository. - // "repo_subdir": "", - - // Customizable commands for building, installing, and - // uninstalling the project. See asv.conf.json documentation. - "install_command": ["python -mpip install {wheel_file}"], - "uninstall_command": ["return-code=any python -mpip uninstall -y {project}"], - "build_command": [ - "in-dir={conf_dir} python build_hpat.py --env-dir {env_dir} --build-dir {build_dir}", - "PIP_NO_BUILD_ISOLATION=false python -mpip wheel --no-deps --no-index -w {build_cache_dir} {build_dir}" - ], - - // List of branches to benchmark. If not provided, defaults to "master" - // (for git) or "default" (for mercurial). - // "branches": ["master"], // for git - // "branches": ["default"], // for mercurial - - // The DVCS being used. If not set, it will be automatically - // determined from "repo" by looking at the protocol in the URL - // (if remote), or by looking for special directories, such as - // ".git" (if local). - "dvcs": "git", - - // The tool to use to create environments. May be "conda", - // "virtualenv" or other value depending on the plugins in use. - // If missing or the empty string, the tool will be automatically - // determined by looking for tools on the PATH environment - // variable. - "environment_type": "hpat_conda", - "plugins": [".asv_hpat_plugin"], - - // timeout in seconds for installing any dependencies in environment - // defaults to 10 min - //"install_timeout": 600, - - // the base URL to show a commit for the project. - // "show_commit_url": "http://github.com/owner/project/commit/", - - // The Pythons you'd like to test against. If not provided, defaults - // to the current version of Python used to run `asv`. - "pythons": ["3.7.4"], - - // The list of conda channel names to be searched for benchmark - // dependency packages in the specified order - "conda_channels": ["ehsantn", "numba/label/dev", "anaconda", "conda-forge", "intel"], - - // The matrix of dependencies to test. Each key is the name of a - // package (in PyPI) and the values are version numbers. An empty - // list or empty string indicates to just test against the default - // (latest) version. null indicates that the package is to not be - // installed. If the package to be tested is only available from - // PyPi, and the 'environment_type' is conda, then you can preface - // the package name by 'pip+', and the package will be installed via - // pip (with all the conda available packages installed first, - // followed by the pip installed packages). - "matrix": { - "boost": ["1.70.0"], - "cmake": ["3.15.1", null], - "gcc_linux-64": ["7.3.0", null], - "gfortran_linux-64": ["7.3.0", null], - "gitpython": ["2.1.13"], - "gxx_linux-64": ["7.3.0", null], - "impi_rt": ["2019.4"], - "mkl-devel": ["2019.4"], - "mpi": ["1.0", null], - "mpich": ["3.2.1", null], - "numba": ["0.46.0dev0=np116py37h6538335_143", "0.46.0dev0=np116py37hf484d3e_143"], - "numpy": ["1.16.4"], - "pandas": ["0.24.2"], - "pyarrow": ["0.14.1"], - "scipy": ["1.2.1"], - "tbb-devel": ["2019.4"], - "vc": ["14.1", null], - "vs2015_runtime": ["14.15.26706", null], - "vs2015_win-64": ["14.0.25420", null] - }, - - // Combinations of libraries/python versions can be excluded/included - // from the set to test. Each entry is a dictionary containing additional - // key-value pairs to include/exclude. - // - // An exclude entry excludes entries where all values match. The - // values are regexps that should match the whole string. - // - // An include entry adds an environment. Only the packages listed - // are installed. The 'python' key is required. The exclude rules - // do not apply to includes. - // - // In addition to package names, the following keys are available: - // - // - python - // Python version, as in the *pythons* variable above. - // - environment_type - // Environment type, as above. - // - sys_platform - // Platform, as in sys.platform. Possible values for the common - // cases: 'linux2', 'win32', 'cygwin', 'darwin'. - // - "exclude": [ - {"sys_platform": "(?!win32).*", "cmake": null}, - {"sys_platform": "(?!win32).*", "mpich": null}, - {"sys_platform": "(?!win32).*", "mpi": null}, - {"sys_platform": "(?!win32).*", "gcc_linux-64": null}, - {"sys_platform": "(?!win32).*", "gxx_linux-64": null}, - {"sys_platform": "(?!win32).*", "gfortran_linux-64": null}, - {"sys_platform": "(?!win32).*", "numba": "0.46.0dev0=np116py37h6538335_143"}, - {"sys_platform": "(?!win32).*", "vc": "14.1"}, - {"sys_platform": "(?!win32).*", "vs2015_runtime": "14.15.26706"}, - {"sys_platform": "(?!win32).*", "vs2015_win-64": "14.0.25420"}, - {"sys_platform": "win32", "cmake": "3.15.1"}, - {"sys_platform": "win32", "mpich": "3.2.1"}, - {"sys_platform": "win32", "mpi": "1.0"}, - {"sys_platform": "win32", "gcc_linux-64": "7.3.0"}, - {"sys_platform": "win32", "gxx_linux-64": "7.3.0"}, - {"sys_platform": "win32", "gfortran_linux-64": "7.3.0"}, - {"sys_platform": "win32", "numba": "0.46.0dev0=np116py37hf484d3e_143"}, - {"sys_platform": "win32", "vc": null}, - {"sys_platform": "win32", "vs2015_runtime": null}, - {"sys_platform": "win32", "vs2015_win-64": null} - ], - // "include": [ - // // additional env for python2.7 - // {"python": "2.7", "numpy": "1.8"}, - // // additional env if run on windows+conda - // {"platform": "win32", "environment_type": "conda", "python": "2.7", "libpython": ""}, - // ], - - // The directory (relative to the current directory) that benchmarks are - // stored in. If not provided, defaults to "benchmarks" - "benchmark_dir": "tests", - - // The directory (relative to the current directory) to cache the Python - // environments in. If not provided, defaults to "env" - "env_dir": "../build/.asv/env", - - // The directory (relative to the current directory) that raw benchmark - // results are stored in. If not provided, defaults to "results". - "results_dir": "../build/.asv/results", - - // The directory (relative to the current directory) that the html tree - // should be written to. If not provided, defaults to "html". - "html_dir": "../build/.asv/html" - - // The number of characters to retain in the commit hashes. - // "hash_length": 8, - - // `asv` will cache results of the recent builds in each - // environment, making them faster to install next time. This is - // the number of builds to keep, per environment. - // "build_cache_size": 2, - - // The commits after which the regression search in `asv publish` - // should start looking for regressions. Dictionary whose keys are - // regexps matching to benchmark names, and values corresponding to - // the commit (exclusive) after which to start looking for - // regressions. The default is to start from the first commit - // with results. If the commit is `null`, regression detection is - // skipped for the matching benchmark. - // - // "regressions_first_commits": { - // "some_benchmark": "352cdf", // Consider regressions only after this commit - // "another_benchmark": null, // Skip regression detection altogether - // }, - - // The thresholds for relative change in results, after which `asv - // publish` starts reporting regressions. Dictionary of the same - // form as in ``regressions_first_commits``, with values - // indicating the thresholds. If multiple entries match, the - // maximum is taken. If no entry matches, the default is 5%. - // - // "regressions_thresholds": { - // "some_benchmark": 0.01, // Threshold of 1% - // "another_benchmark": 0.5, // Threshold of 50% - // }, -} \ No newline at end of file diff --git a/tests_perf/asv_hpat_plugin.py b/tests_perf/asv_hpat_plugin.py deleted file mode 100644 index a4564c818..000000000 --- a/tests_perf/asv_hpat_plugin.py +++ /dev/null @@ -1,109 +0,0 @@ -# ***************************************************************************** -# Copyright (c) 2019, Intel Corporation All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ***************************************************************************** - - -""" -Plugin to run HPAT performance tests under Conda environment via Airspeed Velocity. -""" -import multiprocessing -import os - -from asv import util -from asv.console import log -from asv.plugins.conda import Conda, _find_conda - - -class HPATConda(Conda): - tool_name = 'hpat_conda' - - @property - def conda_executable(self): - """Find conda executable.""" - try: - return _find_conda() - except IOError as e: - raise util.UserError(str(e)) - - def activate_conda(self, executable, args): - """Wrap command with arguments under conda environment""" - return [self.conda_executable, 'run', '-p', self._path, executable] + args - - def activate_mpi(self, executable, args): - """Wrap command with arguments under mpiexec""" - if util.WIN: - # Use processes number from system variable MPIEXEC_NP or system - mpiexec_np = os.environ.get('MPIEXEC_NP', str(multiprocessing.cpu_count())) - mpi_args = ['mpiexec', '-n', mpiexec_np] - else: - # mpiexec under util.check_output hangs on Linux, so temporarily disabling MPI on Linux - mpi_args = [] - - return mpi_args + [executable] + args - - def run(self, args, **kwargs): - log.debug("Running '{0}' in {1}".format(' '.join(args), self.name)) - # mpiexec removes quotes from command line args, so escaping the quotes in the command - escaped_args = [arg.replace('"', '\\"') for arg in args] - executable, *args = self.activate_mpi('python', escaped_args) - - return self.run_executable(executable, args, **kwargs) - - def run_executable(self, executable, args, **kwargs): - env = dict(kwargs.pop('env', os.environ), PYTHONNOUSERSITE='True').copy() - env.update(self._env_vars) - - # Insert bin dirs to PATH - if 'PATH' in env: - paths = env['PATH'].split(os.pathsep) - else: - paths = [] - - if util.WIN: - subpaths = [ - 'Library\\mingw-w64\\bin', - 'Library\\bin', - 'Library\\usr\\bin', - 'Scripts' - ] - for sub in subpaths[::-1]: - paths.insert(0, os.path.join(self._path, sub)) - paths.insert(0, self._path) - else: - paths.insert(0, os.path.join(self._path, 'bin')) - - # Discard PYTHONPATH, which can easily break the environment isolation - if 'ASV_PYTHONPATH' in env: - env['PYTHONPATH'] = env['ASV_PYTHONPATH'] - env.pop('ASV_PYTHONPATH', None) - else: - env.pop('PYTHONPATH', None) - - # When running pip, we need to set PIP_USER to false, as --user (which - # may have been set from a pip config file) is incompatible with virtualenvs. - kwargs['env'] = dict(env, PIP_USER=str('false'), PATH=str(os.pathsep.join(paths))) - conda_cmd = self.activate_conda(executable, args) - - return util.check_output(conda_cmd, **kwargs) diff --git a/tests_perf/asvgen.py b/tests_perf/asvgen.py deleted file mode 100644 index 05a0bc5fb..000000000 --- a/tests_perf/asvgen.py +++ /dev/null @@ -1,122 +0,0 @@ -# ***************************************************************************** -# Copyright (c) 2019, Intel Corporation All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ***************************************************************************** - -""" -HTML report generator based on ASV output as JSON. - -Example usage: -python asvgen.py --asv-results .asv/results --template template/asvgen.html -""" -import argparse -import json -import itertools -from pathlib import Path - -import jinja2 - - -class ASVGen: - machine_json = 'machine.json' - - def __init__(self, results_path, template_path): - """ - :param results_path: path to ASV results - :param template_path: path to HTML template - """ - self.results_path = results_path - self.template_path = template_path - - @property - def result_subdirs(self): - """Result sub-directories""" - return (p for p in self.results_path.iterdir() if p.is_dir()) - - def render_template(self, context): - """ - Render specified HTML template via specified context - - :param name: name of the template file - :param context: context to render template - :param templates_path: path to directory with templates - :return: rendered template - """ - template_loader = jinja2.FileSystemLoader(searchpath=self.template_path.parent.as_posix()) - template_env = jinja2.Environment(loader=template_loader) - template = template_env.get_template(self.template_path.name) - - return template.render(context) - - def generate(self): - """Generate HTML reports based on ASV results""" - for subdir in self.result_subdirs: - machine_info = {} - machine_json_path = subdir / self.machine_json - if machine_json_path.exists(): - with machine_json_path.open(encoding='utf-8') as fd: - machine_info = json.load(fd) - for res_path in subdir.glob('*.json'): - if res_path.name == self.machine_json: - # Skip machine info file - continue - - with res_path.open(encoding='utf-8') as fd: - results = json.load(fd)['results'] - data = {} - for benchmark, result in results.items(): - # combine benchmarks parameters to match parameters combinations and results, e.g.: - # result['params'] = [[0, 1], ['interpreted', 'compiled']] - # params = [(0, 'interpreted'), (0, 'compiled'), (1, 'interpreted'), (1, 'compiled')] - # result['results'] = [1.87, 1.31, 1.85, 1.28] - # def time_smth(0, 'interpreted'): ... => 1.87 - params = itertools.product(*result.get('params', [])) - for params, res, stats in zip(params, result['result'], result['stats']): - bench_args = ', '.join([str(p) for p in params]) - data[f'{benchmark}({bench_args})'] = {'result': res, 'stats': stats} - context = { - 'extra_info': machine_info, - 'data': data - } - rendered_template = self.render_template(context) - output_html = res_path.parent / f'{res_path.stem}.html' - output_html.write_text(rendered_template, encoding='utf-8') - - -def parse_args(): - """Parse command line arguments""" - parser = argparse.ArgumentParser() - parser.add_argument('--asv-results', required='.asv/results', type=Path, help='Path to ASV results directory') - parser.add_argument('--template', default='templates/asvgen.html', type=Path, help='Path to the html template') - - return parser.parse_args() - - -def main(): - args = parse_args() - ASVGen(args.asv_results, args.template).generate() - - -if __name__ == '__main__': - main() diff --git a/tests_perf/benchmark.py b/tests_perf/benchmark.py deleted file mode 100644 index 022cff921..000000000 --- a/tests_perf/benchmark.py +++ /dev/null @@ -1,137 +0,0 @@ -# ***************************************************************************** -# Copyright (c) 2019, Intel Corporation All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ***************************************************************************** - -""" -Loads a benchmark from pickle-file, runs it and dumps results to json-file. -The script is ran under runner.py to run a benchmarking test case in separate process. - -Example usages: -python benchmark.py --bench-pickle time_quantile.pickle --res-json time_quantile.json -""" -import argparse -import inspect -import json -import pickle -import timeit - -from enum import Enum -from pathlib import Path - - -class BenchmarksType(Enum): - """Benchmark types""" - TIME = 'time' - - -class Benchmark: - def __init__(self, name, func, param, sources): - self.name = name - self.func = func - self.param = param - self.source = sources - - self.setup = inspect.getattr_static(sources, 'setup', None) - self.teardown = inspect.getattr_static(sources, 'teardown', None) - - self.instance = sources() - - def run(self): - """Run benchmark with its parameters""" - self.func(self.instance, *self.param) - - def do_setup(self): - """Run setup method of benchmark""" - if self.setup: - self.setup(self.instance, *self.param) - - def redo_setup(self): - """Run teardown and setup methods of benchmark""" - self.do_teardown() - self.do_setup() - - def do_teardown(self): - """Run teardown method of benchmark""" - if self.teardown: - self.teardown(self.instance, *self.param) - - -class TimeBenchmark(Benchmark): - def __init__(self, name, func, param, source, repeat=10, number=1): - super().__init__(name, func, param, source) - self.repeat = repeat - self.number = number - - @classmethod - def from_pickle(cls, file_path): - file_path = Path(file_path) - with file_path.open('rb') as fd: - return pickle.load(fd) - - def to_pickle(self, file_path): - file_path = Path(file_path) - file_path.parent.mkdir(parents=True, exist_ok=True) - with file_path.open('wb') as fd: - return pickle.dump(self, fd) - - def run(self): - """Run benchmark timing""" - - def func(): - return self.func(self.instance, *self.param) - - timer = timeit.Timer( - stmt=func, - setup=self.redo_setup, - timer=timeit.default_timer) - - # Warming up - timeit.timeit(number=1) - - samples = timer.repeat(repeat=self.repeat, number=self.number) - - return [sample / self.number for sample in samples] - - -def parse_args(): - """Parse command line arguments""" - parser = argparse.ArgumentParser() - parser.add_argument('--bench-pickle', required=True, type=Path, help='Path to pickle with benchmark object') - parser.add_argument('--res-json', required=True, type=Path, help='Path to json with resulting samples') - - return parser.parse_args() - - -def main(): - args = parse_args() - - benchmark = TimeBenchmark.from_pickle(args.bench_pickle) - args.res_json.parent.mkdir(parents=True, exist_ok=True) - with args.res_json.open('w', encoding='utf-8') as fd: - json.dump(benchmark.run(), fd) - - -if __name__ == '__main__': - main() diff --git a/tests_perf/build_hpat.py b/tests_perf/build_hpat.py deleted file mode 100644 index 1ab37cc85..000000000 --- a/tests_perf/build_hpat.py +++ /dev/null @@ -1,174 +0,0 @@ -# ***************************************************************************** -# Copyright (c) 2019, Intel Corporation All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ***************************************************************************** - - -""" -Build HPAT from source -Usage: -python build_sdc.py --env-dir --build-dir -""" -import argparse -import logging -import os -import platform -import subprocess - -from pathlib import Path - - -def setup_logging(): - """Setup logger""" - stream_handler = logging.StreamHandler() - stream_handler.setFormatter(logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')) - - logger = logging.getLogger(__name__) - logger.setLevel(level=logging.INFO) - logger.addHandler(stream_handler) - - return logger - - -def get_mpivars_path(): - """Get path to the mpivars script""" - env = os.environ.copy() - if 'I_MPI_ROOT' not in env: - raise EnvironmentError('I_MPI_ROOT not found in the system environment') - - mpi_roots = [Path(mpi_root) for mpi_root in env['I_MPI_ROOT'].split(os.pathsep)] - mpivars_paths = [mpi_root / 'intel64' / 'bin' / 'mpivars.bat' for mpi_root in mpi_roots] - existing_mpivars = [mpivars_path for mpivars_path in mpivars_paths if mpivars_path.exists()] - - if not existing_mpivars: - raise EnvironmentError(f'Could not found neither {", ".join(str(p) for p in mpivars_paths)}') - - first_mpivars_path, *_ = existing_mpivars - - return first_mpivars_path - - -def run_cmd(cmd, cwd=None, env=None): - """ - Run specified command with logging - - :param cmd: command - :param cwd: current working directory - :param env: environment - """ - logger = logging.getLogger(__name__) - - logger.info('Running \'%s\'', subprocess.list2cmdline(cmd)) - proc = subprocess.run(cmd, cwd=cwd, env=env) - logger.info(proc.stdout) - - -def _build_win(cwd, env_dir): - """ - Build HPAT on Windows via the following commands: - set INCLUDE=%INCLUDE%;%CONDA_PREFIX%\\Library\\include - set LIB=%LIB%;%CONDA_PREFIX%\\Library\\lib - "%I_MPI_ROOT%"\\intel64\\bin\\mpivars.bat - python setup.py develop - - :param cwd: current working directory - :param env_dir: conda environment directory - """ - env = os.environ.copy() - - env_library_dir = env_dir / 'Library' - include_dirs = [] - if 'INCLUDE' in env: - include_dirs.append(env['INCLUDE']) - include_dirs.append(f'{env_library_dir / "include"}') - env['INCLUDE'] = os.pathsep.join(include_dirs) - - lib_dirs = [] - if 'LIB' in env: - lib_dirs.append(env['LIB']) - lib_dirs.append(f'{env_library_dir / "lib"}') - env['LIB'] = os.pathsep.join(lib_dirs) - - mpivars_cmd = [f'{get_mpivars_path()}'] - build_cmd = ['python', 'setup.py', 'develop'] - common_cmd = mpivars_cmd + ['&&'] + build_cmd - run_cmd(common_cmd, cwd=cwd, env=env) - - -def _build_lin(cwd, env_dir): - """ - Build HPAT on Linux via the following commands: - python setup.py develop - - :param cwd: current working directory - :param env_dir: conda environment directory - """ - env = os.environ.copy() - - cmd = ['python', 'setup.py', 'develop'] - run_cmd(cmd, cwd=cwd, env=env) - - -def get_builder(): - """Get HPAT builder according to system OS""" - system_platform = platform.system() - if system_platform == 'Windows': - return _build_win - if system_platform == 'Linux': - return _build_lin - - raise ValueError(f'Unknown OS: {system_platform}') - - -class HPATBuilder: - def __init__(self, cwd, env_dir): - self.cwd = cwd - self.env_dir = env_dir - - def build(self): - """Build HPAT via obtained builder""" - builder = get_builder() - return builder(self.cwd, self.env_dir) - - -def parse_args(): - """Parse command line arguments""" - parser = argparse.ArgumentParser() - parser.add_argument('--env-dir', required=True, type=Path, help='Path to the currently active environment root') - parser.add_argument('--build-dir', required=True, type=Path, help='Path to the build directory') - - return parser.parse_args() - - -def main(): - """Main function""" - args = parse_args() - setup_logging() - - hpat_builder = HPATBuilder(cwd=args.build_dir, env_dir=args.env_dir) - hpat_builder.build() - - -if __name__ == "__main__": - main() diff --git a/tests_perf/runner.py b/tests_perf/runner.py deleted file mode 100644 index 890b162ba..000000000 --- a/tests_perf/runner.py +++ /dev/null @@ -1,219 +0,0 @@ -# ***************************************************************************** -# Copyright (c) 2019, Intel Corporation All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ***************************************************************************** - -""" -Performance tests runner runs performance tests implemented as class with attributes: -params (list of lists): values of test parameters -param_names (list): names of test parameters -def setup(): method which runs before each test case -def time_*(): test case -def teardown(): method which runs after each test case - -E.g: -class Methods: - params = [ - [5000513], - [1, 3, 5, 9, 17, 33], - ['interpreted_python', 'compiled_python'] - ] - param_names = ['size', 'nchars', 'implementation'] - - def setup(self, size, nchars, implementation): - self.series = StringSeriesGenerator(size=size, nchars=nchars).generate() - - @staticmethod - @sdc.jit - def _len(series): - return series.str.len() - - def time_len(self, size, nchars, implementation): - if implementation == Impl.compiled_python.value: - return self._len(self.series) - if implementation == Impl.interpreted_python.value: - return self.series.str.len() - -Example usages: -1. Run all: - python runner.py -1. Run tests/strings.py: - python runner.py --bench tests.strings -""" -import argparse -import inspect -import itertools -import json -import logging -import pkgutil -import platform -import statistics -import subprocess -import tempfile - -from collections import defaultdict, OrderedDict -from importlib import import_module -from pathlib import Path - -from tests_perf.benchmark import BenchmarksType, TimeBenchmark - - -EXECUTABLE = 'python' -SCRIPT = 'benchmark.py' - - -def setup_logging(): - """Setup logger""" - stream_handler = logging.StreamHandler() - stream_handler.setFormatter(logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')) - - logger = logging.getLogger(__name__) - logger.setLevel(level=logging.INFO) - logger.addHandler(stream_handler) - - return logger - - -def discover_modules(mnodule_name): - """ - Recursively import a module and all sub-modules in the module - - :param mnodule_name: module name - :return: modules from the package - """ - module = import_module(mnodule_name) - - yield module - - if getattr(module, '__path__', None): - for _, name, _ in pkgutil.iter_modules(module.__path__, f'{mnodule_name}.'): - yield from discover_modules(name) - - -def discover_benchmarks(module_name, type_=BenchmarksType.TIME.value, repeat=10, number=1): - """ - Discover benchmarks in the module - - :param module_name: benchmarks module - :param type_: benchmark type - :return: time benchmarks - """ - for module in discover_modules(module_name): - for attr_name, module_attr in module.__dict__.items(): - if attr_name.startswith('_'): - # skip attributes which start with underscore - continue - - if inspect.isclass(module_attr): - for name, class_attr in inspect.getmembers(module_attr): - if not name.startswith(f'{type_}_'): - continue - - name_parts = module.__name__.split('.', 1)[1:] + [module_attr.__name__, name] - benchmark_name = '.'.join(name_parts) - func = inspect.getattr_static(module_attr, name) - params = inspect.getattr_static(module_attr, 'params', [[]]) - for param in itertools.product(*params): - yield TimeBenchmark(benchmark_name, func, param, module_attr, repeat=repeat, number=number) - - -def run_benchmark(benchmark): - """ - Run specified benchmark in separate process - - :param benchmark: benchmark object - :param env_name: Conda environment name - :param executable: Executable - :return: samples of the run - """ - logger = logging.getLogger(__name__) - bench_file_name = benchmark.name.replace('.', '_') - with tempfile.TemporaryDirectory() as temp_dir: - bench_pickle = Path(temp_dir) / f'{bench_file_name}.pickle' - benchmark.to_pickle(bench_pickle) - samples_json = Path(temp_dir) / f'{bench_file_name}.json' - cmd = [EXECUTABLE, SCRIPT, '--bench-pickle', str(bench_pickle), '--res-json', str(samples_json)] - logger.info('Running "%s"', subprocess.list2cmdline(cmd)) - subprocess.run(cmd, check=True, shell=True) - with samples_json.open(encoding='utf-8') as fd: - return json.load(fd) - - -def compute_stats(samples): - """Statistical analysis of the samples""" - return { - 'min': min(samples), - 'max': max(samples), - 'mean': statistics.mean(samples), - 'std': statistics.stdev(samples) - } - - -def dump_results(results, file_path): - """Dump benchmarking results to json-file""" - file_path.parent.mkdir(parents=True, exist_ok=True) - with file_path.open('w', encoding='utf-8') as fd: - json.dump(results, fd) - - -def parse_args(): - """Parse command line arguments""" - parser = argparse.ArgumentParser() - parser.add_argument('--bench', default='tests', help='Module with performance tests') - parser.add_argument('--number', default=1, type=int, help='Repeat count') - parser.add_argument('--repeat', default=10, type=int, help='Number of executions') - parser.add_argument('--results-dir', default='../build/tests_perf', type=Path, - help='Path to directory with benchmarking results') - - return parser.parse_args() - - -def main(): - args = parse_args() - logger = setup_logging() - - results = defaultdict(list) - logger.info('Running benchmarks in "%s"...', args.bench) - for benchmark in discover_benchmarks(args.bench, repeat=args.repeat, number=args.number): - samples = run_benchmark(benchmark) - results[benchmark.name].append( - {'result': statistics.median(samples), 'stats': compute_stats(samples), 'params': benchmark.param} - ) - logger.info('%s%s: %ss', benchmark.name, benchmark.param, round(statistics.median(samples), 5)) - - formatted_results = {} - for name, res in results.items(): - formatted_results[name] = { - 'result': [r['result'] for r in res], - 'stats': [r['stats'] for r in res], - 'params': [list(OrderedDict.fromkeys(y)) for y in zip(*[r['params'] for r in res])], - } - data = {'results': formatted_results} - results_json = args.results_dir / platform.node() / 'results.json' - dump_results(data, results_json) - logger.info('Results dumped to "%s"', results_json) - - -if __name__ == '__main__': - main() diff --git a/tests_perf/templates/asvgen.html b/tests_perf/templates/asvgen.html deleted file mode 100644 index 1006d8d3e..000000000 --- a/tests_perf/templates/asvgen.html +++ /dev/null @@ -1,54 +0,0 @@ - - - - - Pandas - - - -
-
- {% for key, value in extra_info.items() %} - {%if value %} - {{ key }}: {{ value }}{{ ', ' if not loop.last }} - {% endif %} - {% endfor %} -
-
- - - - - - - - - - - - - - {% for test_name, result in data.items() %} - {% if result['result'] and result['stats'] %} - - - - - - - - - - {% endif %} - {% endfor %} - -
Row #BenchmarkResult, sMin, sArithmetic Mean, sMax, sStandard Deviation, s
{{ loop.index }}{{ test_name }}{{ '%0.5f'| format(result['result']|float) }}{{ '%0.5f'| format(result['stats']['min']|float) }}{{ '%0.5f'| format(result['stats']['mean']|float) }}{{ '%0.5f'| format(result['stats']['max']|float) }}{{ '%0.5f'| format(result['stats']['std']|float) }}
- - \ No newline at end of file diff --git a/tests_perf/tests/__init__.py b/tests_perf/tests/__init__.py deleted file mode 100644 index d15aaf47d..000000000 --- a/tests_perf/tests/__init__.py +++ /dev/null @@ -1,27 +0,0 @@ -# ***************************************************************************** -# Copyright (c) 2019, Intel Corporation All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ***************************************************************************** - - diff --git a/tests_perf/tests/algorithms.py b/tests_perf/tests/algorithms.py deleted file mode 100644 index 9c32ca4d3..000000000 --- a/tests_perf/tests/algorithms.py +++ /dev/null @@ -1,333 +0,0 @@ -# ***************************************************************************** -# Copyright (c) 2019, Intel Corporation All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ***************************************************************************** - - -import sdc - -from .common import Implementation as Impl -from .data_generator import DataGenerator, FloatSeriesGenerator - - -class Quantile(): - params = [[0.5], - ['linear', 'nearest', 'lower', 'higher', 'midpoint'], - ['float', 'int', 'uint'], - [Impl.interpreted_python.value, Impl.compiled_python.value]] - pparam_names = ['quantile', 'interpolation', 'dtype', 'implementation'] - - def setup(self, quantile, interpolation, dtype, implementation): - N = 10 ** 7 - data_generator = DataGenerator() - data = { - 'int': data_generator.make_int_series(N, repeat=5), - 'uint': data_generator.make_uint_series(N, repeat=5), - 'float': data_generator.make_float_series(N, repeat=5), - } - self.idx = data[dtype] - - @staticmethod - @sdc.jit - def _quantile(idx, quantile, interpolation): - return idx.quantile(quantile, interpolation=interpolation) - - def time_quantile(self, quantile, interpolation, dtype, implementation): - if implementation == Impl.compiled_python.value: - return self._quantile(self.idx, quantile, interpolation) - if implementation == Impl.interpreted_python.value: - return self.idx.quantile(quantile, interpolation) - - -class Absolute: - params = [ - [3 * 10 ** 8 + 513], - [Impl.interpreted_python.value, Impl.compiled_python.value] - ] - param_names = ['size', 'implementation'] - - def setup(self, size, implementation): - self.series = FloatSeriesGenerator(size=size).generate() - - @staticmethod - @sdc.jit - def _abs(series): - return series.abs() - - def time_abs(self, size, implementation): - """Time both interpreted and compiled Series.abs""" - if implementation == Impl.compiled_python.value: - return self._abs(self.series) - if implementation == Impl.interpreted_python.value: - return self.series.abs() - - -class ValueCounts: - params = [ - [5 * 10 ** 6 + 513], - [Impl.interpreted_python.value, Impl.compiled_python.value] - ] - param_names = ['size', 'implementation'] - - def setup(self, size, implementation): - self.series = FloatSeriesGenerator(size).generate() - - @staticmethod - @sdc.jit - def _value_counts(series): - return series.value_counts() - - def time_value_counts(self, size, implementation): - """Time both interpreted and compiled Series.value_counts""" - if implementation == Impl.compiled_python.value: - return self._value_counts(self.series) - if implementation == Impl.interpreted_python.value: - return self.series.value_counts() - - -class MinMax: - params = [ - [25 * 10 ** 7 + 513], - [Impl.interpreted_python.value, Impl.compiled_python.value] - ] - param_names = ['size', 'implementation'] - - def setup(self, size, implementation): - self.series = FloatSeriesGenerator(size=size).generate() - - @staticmethod - @sdc.jit - def _min(series): - return series.min() - - def time_min(self, size, implementation): - """Time both interpreted and compiled Series.min""" - if implementation == Impl.compiled_python.value: - return self._min(self.series) - if implementation == Impl.interpreted_python.value: - return self.series.min() - - @staticmethod - @sdc.jit - def _max(series): - return series.max() - - def time_max(self, size, implementation): - """Time both interpreted and compiled Series.max""" - if implementation == Impl.compiled_python.value: - return self._max(self.series) - if implementation == Impl.interpreted_python.value: - return self.series.max() - - -class Correlation: - params = [ - [10 ** 8 + 513], - [Impl.interpreted_python.value, Impl.compiled_python.value] - ] - param_names = ['size', 'implementation'] - - def setup(self, size, implementation): - self.series = FloatSeriesGenerator(size).generate() - self.series2 = FloatSeriesGenerator(size).generate() - - @staticmethod - @sdc.jit - def _cov(series, series2): - return series.cov(series2) - - def time_cov(self, size, implementation): - """Time both interpreted and compiled Series.cov""" - if implementation == Impl.compiled_python.value: - return self._cov(self.series, self.series2) - if implementation == Impl.interpreted_python.value: - return self.series.cov(self.series2) - - @staticmethod - @sdc.jit - def _corr(series, series2): - return series.corr(series2) - - def time_corr(self, size, implementation): - """Time both interpreted and compiled Series.cov""" - if implementation == Impl.compiled_python.value: - return self._corr(self.series, self.series2) - if implementation == Impl.interpreted_python.value: - return self.series.corr(self.series2) - - -class Sum: - params = [ - [10 ** 8 + 513], - [Impl.interpreted_python.value, Impl.compiled_python.value] - ] - param_names = ['size', 'implementation'] - - def setup(self, size, implementation): - self.series = FloatSeriesGenerator(size=size).generate() - - @staticmethod - @sdc.jit - def _sum(series): - return series.sum() - - def time_sum(self, size, implementation): - """Time both interpreted and compiled Series.sum""" - if implementation == Impl.compiled_python.value: - return self._sum(self.series) - if implementation == Impl.interpreted_python.value: - return self.series.sum() - - -class Count: - params = [ - [5 * 10 ** 8 + 513], - [Impl.interpreted_python.value, Impl.compiled_python.value] - ] - param_names = ['size', 'implementation'] - - def setup(self, size, implementation): - self.series = FloatSeriesGenerator(size).generate() - - @staticmethod - @sdc.jit - def _count(series): - return series.count() - - def time_count(self, size, implementation): - """Time both interpreted and compiled Series.count""" - if implementation == Impl.compiled_python.value: - return self._count(self.series) - if implementation == Impl.interpreted_python.value: - return self.series.count() - - -class Nlargest: - params = [ - [5 * 10 ** 7 + 513], - [Impl.interpreted_python.value, Impl.compiled_python.value] - ] - param_names = ['size', 'implementation'] - - def setup(self, size, implementation): - self.series = FloatSeriesGenerator(size).generate() - - @staticmethod - @sdc.jit - def _nlargest(series): - return series.nlargest() - - def time_nlargest(self, size, implementation): - if implementation == Impl.compiled_python.value: - return self._nlargest(self.series) - if implementation == Impl.interpreted_python.value: - return self.series.nlargest() - - -class Nsmallest: - params = [ - [8 * 10 ** 7 + 513], - [Impl.interpreted_python.value, Impl.compiled_python.value] - ] - param_names = ['size', 'implementation'] - - def setup(self, size, implementation): - self.series = FloatSeriesGenerator(size).generate() - - @staticmethod - @sdc.jit - def _nsmallest(series): - return series.nsmallest() - - def time_nsmallest(self, size, implementation): - if implementation == Impl.compiled_python.value: - return self._nsmallest(self.series) - if implementation == Impl.interpreted_python.value: - return self.series.nsmallest() - - -class Var: - params = [ - [2 * 10 ** 8 + 513], - [Impl.interpreted_python.value, Impl.compiled_python.value] - ] - param_names = ['size', 'implementation'] - - def setup(self, size, implementation): - self.series = FloatSeriesGenerator(size).generate() - - @staticmethod - @sdc.jit - def _var(series): - return series.var() - - def time_var(self, size, implementation): - if implementation == Impl.compiled_python.value: - return self._var(self.series) - if implementation == Impl.interpreted_python.value: - return self.series.var() - - -class Mean: - params = [ - [3 * 10 ** 8 + 513], - [Impl.interpreted_python.value, Impl.compiled_python.value] - ] - param_names = ['size', 'implementation'] - - def setup(self, size, implementation): - self.series = FloatSeriesGenerator(size).generate() - - @staticmethod - @sdc.jit - def _mean(series): - return series.mean() - - def time_mean(self, size, implementation): - if implementation == Impl.compiled_python.value: - return self._mean(self.series) - if implementation == Impl.interpreted_python.value: - return self.series.mean() - - -class Median: - params = [ - [6 * 10 ** 7 + 513], - [Impl.interpreted_python.value, Impl.compiled_python.value] - ] - param_names = ['size', 'implementation'] - - def setup(self, size, implementation): - self.series = FloatSeriesGenerator(size).generate() - - @staticmethod - @sdc.jit - def _median(series): - return series.median() - - def time_median(self, size, implementation): - if implementation == Impl.compiled_python.value: - return self._median(self.series) - if implementation == Impl.interpreted_python.value: - return self.series.median() diff --git a/tests_perf/tests/common.py b/tests_perf/tests/common.py deleted file mode 100644 index 5b1e9699b..000000000 --- a/tests_perf/tests/common.py +++ /dev/null @@ -1,53 +0,0 @@ -# ***************************************************************************** -# Copyright (c) 2019, Intel Corporation All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ***************************************************************************** - - -import os - -from enum import Enum - - -class Implementation(Enum): - """Python implementations""" - interpreted_python = 'interpreted_python' - compiled_python = 'compiled_python' - - -class BaseIO: - """Base class for IO benchmarks""" - fname = None - - def remove(self, f): - """Remove created files""" - try: - os.remove(f) - except OSError: - # On Windows, attempting to remove a file that is in use - # causes an exception to be raised - pass - - def teardown(self, *args, **kwargs): - self.remove(self.fname) diff --git a/tests_perf/tests/data_generator.py b/tests_perf/tests/data_generator.py deleted file mode 100644 index 395de251d..000000000 --- a/tests_perf/tests/data_generator.py +++ /dev/null @@ -1,187 +0,0 @@ -# ***************************************************************************** -# Copyright (c) 2019, Intel Corporation All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ***************************************************************************** - - -""" -Input data generator for performance tests. -""" -import contextlib -import string - -from collections.abc import Iterable - -import numpy as np -import pandas as pd - -from numpy.random import randn -from pandas.util import testing as tm - - -class DataGenerator: - N = 10 ** 6 + 513 - SEED = 123 - - def __init__(self, size=None, seed=None): - self.size = size or self.N - self.seed = seed or self.SEED - - @contextlib.contextmanager - def set_seed(self): - """Substitute random seed for context""" - state = np.random.get_state() - np.random.seed(self.seed) - try: - yield - finally: - np.random.set_state(state) - - def generate(self, *args, **kwargs): - """Generate data""" - raise NotImplementedError - - @property - def rand_array(self, *args, **kwargs): - """Random array""" - raise NotImplementedError - - def randu(self, length): - """Generate one random unicode string.""" - return tm.randu(length) - - def range(self, length, repeat=1): - """Generate range with int32 values.""" - return np.arange(length).repeat(repeat) - - def randn(self, length, repeat=1): - """Generate random array with float64 values.""" - return randn(length).repeat(repeat) - - def make_int_series(self, length, repeat=1, index=None, name=None): - """Generate series with float range.""" - data = pd.Int64Index(self.range(length, repeat=repeat)) - return pd.Series(data, index=index, name=name) - - def make_uint_series(self, length, repeat=1, index=None, name=None): - """Generate series with unsigned integers range.""" - data = pd.UInt64Index(self.range(length, repeat=repeat)) - return pd.Series(data, index=index, name=name) - - def make_float_series(self, length, repeat=1, index=None, name=None): - """Generate series with random floats.""" - data = pd.Float64Index(self.randn(length, repeat=repeat)) - return pd.Series(data, index=index, name=name) - - def make_numeric_dataframe(self, length, repeat=1, index=None): - """Generate simple numeric data frame with integers/floats ranges.""" - data = self.range(length, repeat=repeat) - return pd.DataFrame({ - 'A': data, - 'B': data + 1.0, - 'C': data + 2.0, - 'D': data + 3.0, - }, index=index) - - -class SeriesGenerator(DataGenerator): - - def generate(self): - """Generate series""" - return pd.Series(self.rand_array) - - -class StringSeriesGenerator(SeriesGenerator): - NCHARS = [1, 3, 5, 9, 17, 33] - N = 5 * 10 ** 6 + 513 - # RANDS_CHARS = [a-zA-Z] + [0-9] + [ \t\n\r\f\v] - RANDS_CHARS = np.array(list(string.ascii_letters + string.digits + string.whitespace), dtype=(np.str_, 1)) - - def __init__(self, size=None, nchars=None, seed=None): - super().__init__(size=size, seed=seed) - - self.nchars = nchars or self.NCHARS - if not isinstance(self.nchars, Iterable): - self.nchars = [self.nchars] - - self.size = len(self.nchars) * self.size - - @property - def rand_array(self): - """Array of random strings""" - arrays = [] - for n in self.nchars: - arrays.append(self._rand_array(n)) - - result_array = np.concatenate(arrays) - # shuffle strings array - with self.set_seed(): - np.random.shuffle(result_array) - - return result_array - - def _rand_array(self, n): - """Generate an array of random n-size strings""" - if n == 0: - # generate array of empty strings - return np.array(self.size * ['']) - - # generate array of random n-size strings - with self.set_seed(): - return np.random.choice(self.RANDS_CHARS, size=n * self.size).view((np.str_, n)) - - -class WhiteSpaceStringSeriesGenerator(StringSeriesGenerator): - def _rand_array(self, n): - """Generate an array of random n-size strings which start and end with white space""" - if n < 3: - # generate array of white space strings - return np.array(self.size * [' ' * n]) - - # generate array of random n-size strings which start and end with white space - with self.set_seed(): - arr = np.random.choice(self.RANDS_CHARS, size=(n - 2) * self.size).view((np.str_, n - 2)) - np.char.center(arr, n) - return arr - - -class FloatSeriesGenerator(SeriesGenerator): - N = 5 * 10 ** 6 + 513 - - def __init__(self, size=None, seed=None): - super().__init__(size=size, seed=seed) - - @property - def rand_array(self): - """Array of random floats""" - with self.set_seed(): - return np.array(randn(self.size)) - - -class FloatSeriesIndexGenerator(FloatSeriesGenerator): - - def generate(self): - index = StringSeriesGenerator(self.size).generate() - data = FloatSeriesGenerator(self.size).generate() - return pd.Series(data=data, index=index) diff --git a/tests_perf/tests/io/__init__.py b/tests_perf/tests/io/__init__.py deleted file mode 100644 index d15aaf47d..000000000 --- a/tests_perf/tests/io/__init__.py +++ /dev/null @@ -1,27 +0,0 @@ -# ***************************************************************************** -# Copyright (c) 2019, Intel Corporation All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ***************************************************************************** - - diff --git a/tests_perf/tests/io/csv.py b/tests_perf/tests/io/csv.py deleted file mode 100644 index dc0b2e3fd..000000000 --- a/tests_perf/tests/io/csv.py +++ /dev/null @@ -1,56 +0,0 @@ -# ***************************************************************************** -# Copyright (c) 2019, Intel Corporation All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ***************************************************************************** - - -import sdc - -from ..common import BaseIO, Implementation as Impl -from ..data_generator import DataGenerator - - -class ToCSV(BaseIO): - fname = '__test__.csv' - params = [ - [Impl.interpreted_python.value, Impl.compiled_python.value] - ] - pparam_names = ['implementation'] - - def setup(self, implementation): - N = 10 ** 4 - data_generator = DataGenerator() - self.df = data_generator.make_numeric_dataframe(5 * N) - - @staticmethod - @sdc.jit - def _to_csv(df, fname): - return df.to_csv(fname) - - def time_to_csv(self, implementation): - """Time both interpreted and compiled DataFrame.to_csv""" - if implementation == Impl.compiled_python.value: - return self._to_csv(self.df, self.fname) - if implementation == Impl.interpreted_python.value: - return self.df.to_csv(self.fname) diff --git a/tests_perf/tests/series.py b/tests_perf/tests/series.py deleted file mode 100644 index 3c64bc08f..000000000 --- a/tests_perf/tests/series.py +++ /dev/null @@ -1,219 +0,0 @@ -# ***************************************************************************** -# Copyright (c) 2019, Intel Corporation All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ***************************************************************************** - - -import sdc - -from .common import Implementation as Impl -from .data_generator import StringSeriesGenerator, WhiteSpaceStringSeriesGenerator -from .data_generator import FloatSeriesGenerator, FloatSeriesIndexGenerator - - -class String: - params = [ - [StringSeriesGenerator.N], - StringSeriesGenerator.NCHARS, - [Impl.interpreted_python.value, Impl.compiled_python.value] - ] - param_names = ['size', 'nchars', 'implementation'] - - def setup(self, size, nchars, implementation): - self.series = StringSeriesGenerator(size=size, nchars=nchars).generate() - - @staticmethod - @sdc.jit - def _len(series): - return series.str.len() - - def time_len(self, size, nchars, implementation): - """Time both interpreted and compiled Series.str.len""" - if implementation == Impl.compiled_python.value: - return self._len(self.series) - if implementation == Impl.interpreted_python.value: - return self.series.str.len() - - @staticmethod - @sdc.jit - def _capitalize(series): - return series.str.capitalize() - - def time_capitalize(self, size, nchars, implementation): - """Time both interpreted and compiled Series.str.capitalize""" - if implementation == Impl.compiled_python.value: - return self._capitalize(self.series) - if implementation == Impl.interpreted_python.value: - return self.series.str.capitalize() - - @staticmethod - @sdc.jit - def _lower(series): - return series.str.lower() - - def time_lower(self, size, nchars, implementation): - """Time both interpreted and compiled Series.str.lower""" - if implementation == Impl.compiled_python.value: - return self._lower(self.series) - if implementation == Impl.interpreted_python.value: - return self.series.str.lower() - - @staticmethod - @sdc.jit - def _swapcase(series): - return series.str.swapcase() - - def time_swapcase(self, size, nchars, implementation): - """Time both interpreted and compiled Series.str.swapcase""" - if implementation == Impl.compiled_python.value: - return self._swapcase(self.series) - if implementation == Impl.interpreted_python.value: - return self.series.str.swapcase() - - @staticmethod - @sdc.jit - def _title(series): - return series.str.title() - - def time_title(self, size, nchars, implementation): - """Time both interpreted and compiled Series.str.title""" - if implementation == Impl.compiled_python.value: - return self._title(self.series) - if implementation == Impl.interpreted_python.value: - return self.series.str.title() - - @staticmethod - @sdc.jit - def _upper(series): - return series.str.upper() - - def time_upper(self, size, nchars, implementation): - """Time both interpreted and compiled Series.str.upper""" - if implementation == Impl.compiled_python.value: - return self._upper(self.series) - if implementation == Impl.interpreted_python.value: - return self.series.str.upper() - - -class WhiteSpaceString: - params = [ - [WhiteSpaceStringSeriesGenerator.N], - WhiteSpaceStringSeriesGenerator.NCHARS, - [Impl.interpreted_python.value, Impl.compiled_python.value] - ] - param_names = ['size', 'nchars', 'implementation'] - - def setup(self, size, nchars, implementation): - self.series = WhiteSpaceStringSeriesGenerator(size=size, nchars=nchars).generate() - - @staticmethod - @sdc.jit - def _lstrip(series): - return series.str.lstrip() - - def time_lstrip(self, size, nchars, implementation): - """Time both interpreted and compiled Series.str.lstrip""" - if implementation == Impl.compiled_python.value: - return self._lstrip(self.series) - if implementation == Impl.interpreted_python.value: - return self.series.str.lstrip() - - @staticmethod - @sdc.jit - def _rstrip(series): - return series.str.rstrip() - - def time_rstrip(self, size, nchars, implementation): - """Time both interpreted and compiled Series.str.rstrip""" - if implementation == Impl.compiled_python.value: - return self._rstrip(self.series) - if implementation == Impl.interpreted_python.value: - return self.series.str.rstrip() - - @staticmethod - @sdc.jit - def _strip(series): - return series.str.strip() - - def time_strip(self, size, nchars, implementation): - """Time both interpreted and compiled Series.str.strip""" - if implementation == Impl.compiled_python.value: - return self._strip(self.series) - if implementation == Impl.interpreted_python.value: - return self.series.str.strip() - - -class SortValues: - params = [ - [2 * 10 ** 6 + 513], - [Impl.interpreted_python.value, Impl.compiled_python.value] - ] - param_names = ['size', 'implementation'] - - def setup(self, size, implementation): - self.series = FloatSeriesGenerator(size=size).generate() - - @staticmethod - @sdc.jit - def _sort_values(series): - return series.sort_values() - - def time_sort_values(self, size, implementation): - if implementation == Impl.compiled_python.value: - return self._sort_values(self.series) - if implementation == Impl.interpreted_python.value: - return self.series.sort_values() - - -class IdxMaxMin: - params = [ - [10 ** 5], - [Impl.interpreted_python.value, Impl.compiled_python.value] - ] - param_names = ['size', 'implementation'] - - def setup(self, size, implementation): - self.series = FloatSeriesIndexGenerator(size=size).generate() - - @staticmethod - @sdc.jit - def _idxmax(series): - return series.idxmax() - - def time_idxmax(self, size, implementation): - if implementation == Impl.compiled_python.value: - return self._idxmax(self.series) - if implementation == Impl.interpreted_python.value: - return self.series.idxmax() - - @staticmethod - @sdc.jit - def _idxmin(series): - return series.idxmin() - - def time_idxmin(self, size, implementation): - if implementation == Impl.compiled_python.value: - return self._idxmin(self.series) - if implementation == Impl.interpreted_python.value: - return self.series.idxmin() diff --git a/tests_perf/tests/unicode_strings.py b/tests_perf/tests/unicode_strings.py deleted file mode 100644 index 1059b064c..000000000 --- a/tests_perf/tests/unicode_strings.py +++ /dev/null @@ -1,82 +0,0 @@ -# ***************************************************************************** -# Copyright (c) 2019, Intel Corporation All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# -# Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# ***************************************************************************** - - -import numba - -from .common import Implementation as Impl -from .data_generator import DataGenerator - - -class Methods: - params = [ - [Impl.interpreted_python.value, Impl.compiled_python.value] - ] - param_names = ['implementation'] - - def setup(self, implementation): - N = 10 ** 4 - data_generator = DataGenerator() - self.s = data_generator.randu(N) - - -class WidthMethods(Methods): - def setup(self, implementation): - super().setup(implementation) - self.width = 10 ** 8 - - @staticmethod - @numba.njit - def _center(s, width): - return s.center(width) - - def time_center(self, implementation): - if implementation == Impl.compiled_python.value: - return self._center(self.s, self.width) - if implementation == Impl.interpreted_python.value: - return self.s.center(self.width) - - @staticmethod - @numba.njit - def _ljust(s, width): - return s.ljust(width) - - def time_ljust(self, implementation): - if implementation == Impl.compiled_python.value: - return self._rjust(self.s, self.width) - if implementation == Impl.interpreted_python.value: - return self.s.rjust(self.width) - - @staticmethod - @numba.njit - def _rjust(s, width): - return s.rjust(width) - - def time_rjust(self, implementation): - if implementation == Impl.compiled_python.value: - return self._rjust(self.s, self.width) - if implementation == Impl.interpreted_python.value: - return self.s.rjust(self.width)