https://www.cnblogs.com/miloyip/archive/2010/07/07/languages_brawl_GI.html

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
brew install libomp
gcc -Xpreprocessor -fopenmp -lomp
g++ -O3 -Xpreprocessor -fopenmp -lomp smallpt.cpp -o smallpt
openmp
Rendering (100 spp) 35.29%%
8.384659 sec

real 0m1.559s
user 0m8.330s
sys 0m0.133s

1.559s M1 8核 预计普通模式8s以上 单核

无openmp
Rendering (100 spp) 100.00%
5.823110 sec

real 0m6.874s
user 0m5.831s
sys 0m0.007s

-O0 24.939928 sec
-O1 13.468371 sec
-O2 5.418199 sec
-Os 5.406158 sec
-O3 5.815363 sec

单核

java openjdk 17.0.2
Rendering (100 spp) 100.00%
7.595000 sec
real 0m7.731s
user 0m8.040s
sys 0m0.159s

单核

5.406158/7.595=7118 70%的性能

c#
# dotnet /opt/homebrew/opt/dotnet/libexec/sdk/6.0.103/Roslyn/bincore/csc.dll /r:/opt/homebrew/Cellar/dotnet/6.0.103/libexec/sdk/6.0.103/ref/netstandard.dll smallpt.cs

time dotnet run -c Release #for smallpt_ref.cs

Rendering (100 spp) 100.00%
7.923316 sec

real 0m9.841s
user 0m10.294s
sys 0m0.322s

至少在M1上 c# (dotnet 6.0) 不比 java (openjdk 17.0.2占据优势)

luajit
Rendering (100 spp) 100.00%
149.366208 sec

real 2m29.987s
user 2m29.046s
sys 0m0.356s

149.366s M1 1核

32x32 1.833572 sec

lua 改为32x32 难度降为1/64
Rendering (100 spp) 100.00%
7.425509 sec

real 0m7.928s
user 0m7.428s
sys 0m0.009s

7.43s M1 1核
预计原本耗时7.43*64=
python 太慢 改为32x32 难度降为1/64
Rendering (100 spp) 100.00%
63.590930291999996 sec
real 1m3.654s
user 1m3.581s
sys 0m0.034s

预计原本耗时63.59*64=4069.76

ruby2 改为32x32 难度降为1/64
Rendering (4 spp) 100.00%
4.593397 sec
real 0m4.682s
user 0m4.643s
sys 0m0.025s

预计原本耗时4.59*64=293.76
实际

export PATH="/opt/homebrew/opt/ruby/bin:$PATH"
ruby3 改为32x32 难度降为1/64
Rendering (4 spp) 100.00%
3.897925 sec
real 0m3.971s
user 0m3.943s
sys 0m0.023s
预计原本耗时3.897925*64=249.4672
实际258.469646 sec

js
firefox 62.16s 1core
chrome 37.548s 1core
safari 41.979s 1core
1
2
# 单层循环差异预计
C 1 Java 0.85 Js 0.45 LuaJit 0.18 Ruby3 0.16 Ruby2 0.13 Lua 0.1 Python 0.03

https://developer.nvidia.com/gpugems/gpugems3/part-iii-rendering/chapter-20-gpu-based-importance-sampling
https://zhuanlan.zhihu.com/p/44671434
http://www.kevinbeason.com/smallpt/

https://www.shadertoy.com/view/MlcczX CosineWeightedSampleOnHemisphere
https://zhuanlan.zhihu.com/p/360420413 多重重要性采样/低差异序列

https://raytracing.github.io/books/RayTracingInOneWeekend.html