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