|
| 1 | + |
| 2 | +# cython: language_level=3 |
| 3 | +# -*- coding: utf-8 -*- |
| 4 | +# ***************************************************************************** |
| 5 | +# Copyright (c) 2016-2020, Intel Corporation |
| 6 | +# All rights reserved. |
| 7 | +# |
| 8 | +# Redistribution and use in source and binary forms, with or without |
| 9 | +# modification, are permitted provided that the following conditions are met: |
| 10 | +# - Redistributions of source code must retain the above copyright notice, |
| 11 | +# this list of conditions and the following disclaimer. |
| 12 | +# - Redistributions in binary form must reproduce the above copyright notice, |
| 13 | +# this list of conditions and the following disclaimer in the documentation |
| 14 | +# and/or other materials provided with the distribution. |
| 15 | +# |
| 16 | +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 17 | +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 18 | +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 19 | +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
| 20 | +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 21 | +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 22 | +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 23 | +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 24 | +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 25 | +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
| 26 | +# THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | +# ***************************************************************************** |
| 28 | + |
| 29 | +import pytest |
| 30 | + |
| 31 | +import dpnp |
| 32 | +import numpy as np |
| 33 | + |
| 34 | +ROUNDS=30 |
| 35 | +ITERATIONS=4 |
| 36 | + |
| 37 | +NNUMBERS=2**26 |
| 38 | + |
| 39 | +@pytest.mark.parametrize("function", [dpnp.random.beta, np.random.beta], |
| 40 | + ids=["dpnp", "numpy"]) |
| 41 | +def test_beta(benchmark, function): |
| 42 | + result = benchmark.pedantic(target=function, args=(4.0, 5.0, NNUMBERS,), |
| 43 | + rounds=ROUNDS, iterations=ITERATIONS) |
| 44 | + |
| 45 | + |
| 46 | +@pytest.mark.parametrize("function", [dpnp.random.exponential, np.random.exponential], |
| 47 | + ids=["dpnp", "numpy"]) |
| 48 | +def test_exponential(benchmark, function): |
| 49 | + result = benchmark.pedantic(target=function, args=(4.0, NNUMBERS,), |
| 50 | + rounds=ROUNDS, iterations=ITERATIONS) |
| 51 | + |
| 52 | + |
| 53 | +@pytest.mark.parametrize("function", [dpnp.random.gamma, np.random.gamma], |
| 54 | + ids=["dpnp", "numpy"]) |
| 55 | +def test_gamma(benchmark, function): |
| 56 | + result = benchmark.pedantic(target=function, args=(2.0, 4.0, NNUMBERS,), |
| 57 | + rounds=ROUNDS, iterations=ITERATIONS) |
| 58 | + |
| 59 | + |
| 60 | +@pytest.mark.parametrize("function", [dpnp.random.normal, np.random.normal], |
| 61 | + ids=["dpnp", "numpy"]) |
| 62 | +def test_normal(benchmark, function): |
| 63 | + result = benchmark.pedantic(target=function, args=(0.0, 1.0, NNUMBERS,), |
| 64 | + rounds=ROUNDS, iterations=ITERATIONS) |
| 65 | + |
| 66 | + |
| 67 | +@pytest.mark.parametrize("function", [dpnp.random.uniform, np.random.uniform], |
| 68 | + ids=["dpnp", "numpy"]) |
| 69 | +def test_uniform(benchmark, function): |
| 70 | + result = benchmark.pedantic(target=function, args=(0.0, 1.0, NNUMBERS,), |
| 71 | + rounds=ROUNDS, iterations=ITERATIONS) |
0 commit comments