10000 Merge pull request #13850 from bashtage/random-perf · rkern/numpy@4178b5a · GitHub
[go: up one dir, main page]

Skip to content

Commit 4178b5a

Browse files
authored
Merge pull request numpy#13850 from bashtage/random-perf
DOC: Update performance numbers
2 parents 68bba61 + f2b0ff4 commit 4178b5a

File tree

2 files changed

+72
-59
lines changed

2 files changed

+72
-59
lines changed

doc/source/reference/random/performance.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,16 @@
5454
col[key] = 1000 * min(t)
5555
table['RandomState'] = pd.Series(col)
5656

57+
columns = ['MT19937','PCG64','Philox','SFC64', 'RandomState']
5758
table = pd.DataFrame(table)
58-
table = table.reindex(table.mean(1).sort_values().index)
5959
order = np.log(table).mean().sort_values().index
6060
table = table.T
61-
table = table.reindex(order)
61+
table = table.reindex(columns)
6262
table = table.T
6363
table = table.reindex([k for k in funcs], axis=0)
6464
print(table.to_csv(float_format='%0.1f'))
6565

66+
6667
rel = table.loc[:, ['RandomState']].values @ np.ones(
6768
(1, table.shape[1])) / table
6869
rel.pop('RandomState')
@@ -72,3 +73,15 @@
7273
rel = np.round(rel)
7374
rel = rel.T
7475
print(rel.to_csv(float_format='%0d'))
76+
77+
# Cross-platform table
78+
rows = ['32-bit Unsigned Ints','64-bit Unsigned Ints','Uniforms','Normals','Exponentials']
79+
xplat = rel.reindex(rows, axis=0)
80+
xplat = 100 * (xplat / xplat.MT19937.values[:,None])
81+
overall = np.exp(np.log(xplat).mean(0))
82+
xplat = xplat.T.copy()
83+
xplat['Overall']=overall
84+
print(xplat.T.round(1))
85+
86+
87+

doc/source/reference/random/performance.rst

Lines changed: 57 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -29,38 +29,37 @@ The column labeled MT19973 is used the same 32-bit generator as
2929
:class:`~generator.Generator`.
3030

3131
.. csv-table::
32-
:header: ,PCG64,MT19937,Philox,RandomState
33-
:widths: 14,14,14,14,14
34-
35-
32-bit Unsigned Ints,3.2,3.3,4.8,3.2
36-
64-bit Unsigned Ints,4.8,5.7,6.9,5.7
37-
Uniforms,5.0,7.3,8.0,7.3
38-
Normals,11.3,13.0,13.7,34.4
39-
Exponentials,6.7,7.9,8.6,40.3
40-
Gammas,30.6,34.2,35.1,58.1
41-
Binomials,25.7,27.7,28.4,25.9
42-
Laplaces,41.1,44.5,45.4,46.9
43-
Poissons,58.1,68.4,70.2,86.0
44-
32+
:header: ,MT19937,PCG64,Philox,SFC64,RandomState
33+
:widths: 14,14,14,14,14,14
34+
35+
32-bit Unsigned Ints,4.1,3.3,4.8,2.7,3.2
36+
64-bit Unsigned Ints,5.9,5.0,6.4,2.7,5.6
37+
Uniforms,7.4,5.2,8.1,3.1,7.3
38+
Normals,13.0,11.4,13.1,7.8,33.9
39+
Exponentials,8.0,6.6,8.5,4.1,39.8
40+
Gammas,36.5,31.3,34.8,27.5,57.9
41+
Binomials,25.6,23.1,26.0,19.8,25.0
42+
Laplaces,45.8,41.9,45.4,38.0,45.5
43+
Poissons,67.9,57.7,68.3,58.7,80.8
4544

4645
The next table presents the performance in percentage relative to values
4746
generated by the legagy generator, `RandomState(MT19937())`. The overall
4847
performance was computed using a geometric mean.
4948

5049
.. csv-table::
51-
:header: ,PCG64,MT19937,Philox
52-
:widths: 14,14,14,14
53-
54-
32-bit Unsigned Ints,100,99,67
55-
64-bit Unsigned Ints,118,100,83
56-
Uniforms,147,100,91
57-
Normals,304,264,252
58-
Exponentials,601,512,467
59-
Gammas,190,170,166
60-
Binomials,101,93,91
61-
Laplaces,114,105,103
62-
Poissons,148,126,123
63-
Overall,167,145,131
50+
:header: ,MT19937,PCG64,Philox,SFC64
51+
:widths: 14,14,14,14,14
52+
53+
32-bit Unsigned Ints,77,96,66,116
54+
64-bit Unsigned Ints,95,112,86,206
55+
Uniforms,99,140,90,235
56+
Normals,260,296,258,437
57+
Exponentials,497,600,467,974
58+
Gammas,159,185,166,211
59+
Binomials,98,108,96,126
60+
Laplaces,99,109,100,120
61+
Poissons,119,140,118,138
62+
Overall,137,163,131,217
6463

6564
.. note::
6665

@@ -81,33 +80,34 @@ across tables.
8180
64-bit Linux
8281
~~~~~~~~~~~~
8382

84-
=================== ========= ======= ========
85-
Distribution MT19937 PCG64 Philox
86-
=================== ========= ======= ========
87-
32-bit Unsigned Int 100 113.9 72.1
88-
64-bit Unsigned Int 100 143.3 89.7
89-
Uniform 100 181.5 90.8
90-
Exponential 100 145.5 92.5
91-
Normal 100 121.4 98.3
92-
**Overall** 100 139.3 88.2
93-
=================== ========= ======= ========
83+
=================== ========= ======= ======== =======
84+
Distribution MT19937 PCG64 Philox SFC64
85+
=================== ========= ======= ======== =======
86+
32-bit Unsigned Int 100 98.0 67.7 120.2
87+
64-bit Unsigned Int 100 120.4 90.8 213.3
88+
Uniforms 100 141.0 87.0 232.0
89+
Normals 100 115.7 99.2 167.8
90+
Exponentials 100 116.8 93.0 189.3
91+
**Overall** 100 117.6 86.8 180.0
92+
=================== ========= ======= ======== =======
9493

9594

9695
64-bit Windows
9796
~~~~~~~~~~~~~~
98-
The performance on 64-bit Linux and 64-bit Windows is broadly similar.
97+
The relative performance on 64-bit Linux and 64-bit Windows is broadly similar.
98+
9999

100+
=================== ========= ======= ======== =======
101+
Distribution MT19937 PCG64 Philox SFC64
102+
=================== ========= ======= ======== =======
103+
32-bit Unsigned Int 100 129.1 35.0 135.0
104+
64-bit Unsigned Int 100 146.9 35.7 176.5
105+
Uniforms 100 165.0 37.0 192.0
106+
Normals 100 128.5 48.5 158.0
107+
Exponentials 100 151.6 39.0 172.8
108+
**Overall** 100 143.6 38.7 165.7
109+
=================== ========= ======= ======== =======
100110

101-
=================== ========= ======= ========
102-
Distribution MT19937 PCG64 Philox
103-
=================== ========= ======= ========
104-
32-bit Unsigned Int 100 134.9 44.1
105-
64-bit Unsigned Int 100 162.7 41.0
106-
Uniform 100 200.0 44.8
107-
Exponential 100 167.8 47.4
108-
Normal 100 135.6 60.3
109-
**Overall** 100 158.4 47.1
110-
=================== ========= ======= ========
111111

112112
32-bit Windows
113113
~~~~~~~~~~~~~~
@@ -116,16 +116,16 @@ The performance of 64-bit generators on 32-bit Windows is much lower than on 64-
116116
operating systems due to register width. MT19937, the generator that has been
117117
in NumPy since 2005, operates on 32-bit integers.
118118

119-
=================== ========= ======= ========
120-
Distribution MT19937 PCG64 Philox
121-
=================== ========= ======= ========
122-
32-bit Unsigned Int 100 30.6 28.1
123-
64-bit Unsigned Int 100 24.2 23.7
124-
Uniform 100 26.7 28.4
125-
Exponential 100 32.1 32.6
126-
Normal 100 36.3 37.5
127-
**Overall** 100 29.7 29.7
128-
=================== ========= ======= ========
119+
=================== ========= ======= ======== =======
120+
Distribution MT19937 PCG64 Philox SFC64
121+
=================== ========= ======= ======== =======
122+
32-bit Unsigned Int 100 30.5 21.1 77.9
123+
64-bit Unsigned Int 100 26.3 19.2 97.0
124+
Uniforms 100 28.0 23.0 106.0
125+
Normals 100 40.1 31.3 112.6
126+
Exponentials 100 33.7 26.3 109.8
127+
**Overall** 100 31.4 23.8 99.8
128+
=================== ========= ======= ======== =======
129129

130130

131131
.. note::

0 commit comments

Comments
 (0)
0