-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathresults.txt
333 lines (222 loc) · 7.95 KB
/
results.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
Overview
========
100 rays
1 million triangles
All tests were performed on a MacBook Pro (Mid 2014), 2.2 GHz Intel Core i7,
16 GB RAM running OS X El Capitan 10.11.6.
Nim version:
Nim Compiler Version 0.16.1 (2017-03-27) [MacOSX: amd64]
Clang version:
Apple LLVM version 7.3.0 (clang-703.0.31)
Target: x86_64-apple-darwin15.3.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
Java version:
java version "1.8.0_112"
Java(TM) SE Runtime Environment (build 1.8.0_112-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.112-b16, mixed mode)
Node version:
v4.4.7
CPython 2 version:
2.7.13
CPython 3 version:
3.5.2
PyPy version:
Python 2.7.13 (fa3249d55d15b9829e1be69cdf45b5a44cec902d, Mar 27 2017, 13:42:09)
[PyPy 5.7.0 with GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)]
Go version:
go version go1.10 linux/amd64
Commands used to run the tests:
C++: gcc -std=c++11 -lm -O3 -ffast-math -o perftest perftest.cpp && ./perftest
Nim: nim c -r -d:release perftestN.nim
Java: javac Ray.java Vec3.java PerfTest.java && java -cp . PerfTest
Node: node perftest.js
Go: go run perftest.go
Results
=======
perftest.cpp
------------
Total intersection tests: 100,000,000
Hits: 4,994,583 ( 4.99%)
Misses: 95,005,417 (95.01%)
Total time: 1.93 seconds
Millions of tests per second: 51.87
perftest1.nim
-------------
[GLM]
Total intersection tests: 100,000,000
Hits: 4,703,478 ( 4.70%)
Misses: 95,296,522 (95.30%)
Total time: 19.86 seconds
Millions of tests per second: 5.04
perftest2.nim
-------------
[custom vector implementation (object references)]
Total intersection tests: 100,000,000
Hits: 5,718,606 ( 5.72%)
Misses: 94,281,394 (94.28%)
Total time: 11.41 seconds
Millions of tests per second: 8.76
perftest3.nim
-------------
[custom vector implementation (objects)]
Total intersection tests: 100,000,000
Hits: 5,206,370 ( 5.21%)
Misses: 94,793,630 (94.79%)
Total time: 1.96 seconds
Millions of tests per second: 50.93
perftest4.nim
-------------
[vector module]
Total intersection tests: 100,000,000
Hits: 5,237,698 ( 5.24%)
Misses: 94,762,302 (94.76%)
Total time: 2.89 seconds
Millions of tests per second: 34.55
perftest5.nim
-------------
[vector module with inlines]
Total intersection tests: 100,000,000
Hits: 4,640,926 ( 4.64%)
Misses: 95,359,074 (95.36%)
Total time: 1.96 seconds
Millions of tests per second: 51.12
Java
----
100 rays, num triangles varies
Total intersection tests: 100,000
Hits: 4,472 ( 4.47%)
Misses: 95,528 (95.53%)
Total time: 0.01 seconds
Millions of tests per second: 11.11
Total intersection tests: 1,000,000
Hits: 49,531 ( 4.95%)
Misses: 950,469 (95.05%)
Total time: 0.04 seconds
Millions of tests per second: 25.64
Total intersection tests: 10,000,000
Hits: 389,514 ( 3.90%)
Misses: 9,610,486 (96.10%)
Total time: 0.27 seconds
Millions of tests per second: 37.45
Total intersection tests: 100,000,000
Hits: 4,238,899 ( 4.24%)
Misses: 95,761,101 (95.76%)
Total time: 3.20 seconds
Millions of tests per second: 31.27
BUT not slowdown with Nim (using perftest5.nim):
Total intersection tests: 100,000
Hits: 4,546 ( 4.55%)
Misses: 95,454 (95.45%)
Total time: 0.00 seconds
Millions of tests per second: 50.56
(Below 100k tests even Nim slows down, probably some overhead starts taking
over.)
JavaScript
----------
100 rays, num triangles varies
Total intersection tests: 100000
Hits: 3816 (3.82%)
Misses: 96184 (96.18%)
Total time: 0.01 seconds
Millions of tests per second: 9.02
Total intersection tests: 1000000
Hits: 41090 (4.11%)
Misses: 958910 (95.89%)
Total time: 0.05 seconds
Millions of tests per second: 20.49
Total intersection tests: 10000000
Hits: 402791 (4.03%)
Misses: 9597209 (95.97%)
Total time: 0.34 seconds
Millions of tests per second: 29.66
Total intersection tests: 100000000
Hits: 4399082 (4.4%)
Misses: 95600918 (95.6%)
Total time: 3.43 seconds
Millions of tests per second: 29.15
CPython2
========
Total intersection tests: 100000000
Hits: 4232693 ( 4.23%)
Misses: 95767307 (95.77%)
Total time: 508.68 seconds
Millions of tests per second: 0.20
CPython3
========
Total time: 673.66 seconds
Millions of tests per second: 0.14
PyPy
====
Total intersection tests: 100000
Hits: 4792 ( 4.79%)
Misses: 95208 (95.21%)
Total time: 0.10 seconds
Millions of tests per second: 1.03
Total intersection tests: 1000000
Hits: 47737 ( 4.77%)
Misses: 952263 (95.23%)
Total time: 0.26 seconds
Millions of tests per second: 3.82
Total intersection tests: 10000000
Hits: 432154 ( 4.32%)
Misses: 9567846 (95.68%)
Total time: 1.09 seconds
Millions of tests per second: 9.15
Total intersection tests: 100000000
Hits: 4645003 ( 4.65%)
Misses: 95354997 (95.35%)
Total time: 9.51 seconds
Millions of tests per second: 10.51
Summary
=======
Test M test/s Rel.perf.
--------------------------------
C++ 51.9 1.00x
Nim 51.1 0.98x
Java 31.3 0.60x
JavaScript 29.2 0.56x
PyPy 10.5 0.20x
CPython2 0.20 0.004x
CPython3 0.14 0.003x
Real life example (rendering an image):
3 hours (C++, Nim)
5 hours (Java, JavaScript)
15 hours (PyPy)
30 days (CPython2)
40 days (CPython3)
Further optimisations:
45 mins (C++, Nim w/ multi-threading & SIMD) 1.00x
2.5 hours (Java w/ multi-threading) 0.30x
5 hours (JavaScript, no further optimisations possible) 0.15x
Test M test/s Rel.perf.
-----------------------------------------------------
Nim - nim-glm 5.0 0.09x
Nim - custom (ref objects) 8.8 0.17x
Nim - custom (objects) 50.9 0.98x
Nim - vector module 34.6 0.67x
Nim - vector module w/ inlines 51.1 0.98x
Java
Tests M test/s Rel.perf.
----------------------------
100K 11.1 0.21x
1M 25.7 0.49x
10M 37.4 0.72x
100M 31.3 0.60x
JavaScript
Tests M test/s Rel.perf.
----------------------------
100K 9.0 0.17x
1M 20.5 0.39x
10M 29.7 0.57x
100M 29.2 0.56x
PyPy
Tests M test/s Rel.perf.
----------------------------
100K 1.0 0.02x
1M 3.8 0.07x
10M 9.2 0.18x
100M 10.5 0.20x
Appendix
========
[2019-08-01] The Go implementation contributed by n1try scored 54.8 M tests/s on a 12-core 3.6 Ghz machine, which is 14 % faster than the C++ version (48.24 M tests/s) run on the same machine.