summaryrefslogtreecommitdiffhomepage
path: root/benchmark
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2017-11-22 16:09:50 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2017-11-22 16:09:50 +0900
commitb4f9b031deaf7c75dad7aa10f2318bb37e268fa3 (patch)
tree6e38cc9b61330d34d09e157bca406dc1b084198c /benchmark
parent284a1d12ee6b0fdd77b042771f5db833112fc14e (diff)
downloadmruby-b4f9b031deaf7c75dad7aa10f2318bb37e268fa3.tar.gz
mruby-b4f9b031deaf7c75dad7aa10f2318bb37e268fa3.zip
Some cosmetic changes
Diffstat (limited to 'benchmark')
-rw-r--r--benchmark/bm_ao_render.rb30
-rw-r--r--benchmark/bm_so_lists.rb6
2 files changed, 18 insertions, 18 deletions
diff --git a/benchmark/bm_ao_render.rb b/benchmark/bm_ao_render.rb
index 8212c3a13..dc4388c7d 100644
--- a/benchmark/bm_ao_render.rb
+++ b/benchmark/bm_ao_render.rb
@@ -68,7 +68,7 @@ class Vec
def vnormalize
len = vlength
v = Vec.new(@x, @y, @z)
- if len > 1.0e-17 then
+ if len > 1.0e-17
v.x = v.x / len
v.y = v.y / len
v.z = v.z / len
@@ -92,10 +92,10 @@ class Sphere
b = rs.vdot(ray.dir)
c = rs.vdot(rs) - (@radius * @radius)
d = b * b - c
- if d > 0.0 then
+ if d > 0.0
t = - b - Math.sqrt(d)
- if t > 0.0 and t < isect.t then
+ if t > 0.0 and t < isect.t
isect.t = t
isect.hit = true
isect.pl = Vec.new(ray.org.x + ray.dir.x * t,
@@ -118,16 +118,16 @@ class Plane
v = ray.dir.vdot(@n)
v0 = v
- if v < 0.0 then
+ if v < 0.0
v0 = -v
end
- if v0 < 1.0e-17 then
+ if v0 < 1.0e-17
return
end
t = -(ray.org.vdot(@n) + d) / v
- if t > 0.0 and t < isect.t then
+ if t > 0.0 and t < isect.t
isect.hit = true
isect.t = t
isect.n = @n
@@ -170,10 +170,10 @@ end
def clamp(f)
i = f * 255.5
- if i > 255.0 then
+ if i > 255.0
i = 255.0
end
- if i < 0.0 then
+ if i < 0.0
i = 0.0
end
i.to_i
@@ -183,11 +183,11 @@ def otherBasis(basis, n)
basis[2] = Vec.new(n.x, n.y, n.z)
basis[1] = Vec.new(0.0, 0.0, 0.0)
- if n.x < 0.6 and n.x > -0.6 then
+ if n.x < 0.6 and n.x > -0.6
basis[1].x = 1.0
- elsif n.y < 0.6 and n.y > -0.6 then
+ elsif n.y < 0.6 and n.y > -0.6
basis[1].y = 1.0
- elsif n.z < 0.6 and n.z > -0.6 then
+ elsif n.z < 0.6 and n.z > -0.6
basis[1].z = 1.0
else
basis[1].x = 1.0
@@ -221,8 +221,8 @@ class Scene
p0 = Vec.new(isect.pl.x + eps * isect.n.x,
isect.pl.y + eps * isect.n.y,
isect.pl.z + eps * isect.n.z)
- nphi.times do |j|
- ntheta.times do |i|
+ nphi.times do
+ ntheta.times do
r = Rand::rand
phi = 2.0 * 3.14159265 * Rand::rand
x = Math.cos(phi) * Math.sqrt(1.0 - r)
@@ -241,7 +241,7 @@ class Scene
@spheres[1].intersect(ray, occisect)
@spheres[2].intersect(ray, occisect)
@plane.intersect(ray, occisect)
- if occisect.hit then
+ if occisect.hit
occlusion = occlusion + 1.0
else
0.0
@@ -283,7 +283,7 @@ class Scene
@spheres[1].intersect(ray, isect)
@spheres[2].intersect(ray, isect)
@plane.intersect(ray, isect)
- if isect.hit then
+ if isect.hit
col = ambient_occlusion(isect)
rad.x = rad.x + col.x
rad.y = rad.y + col.y
diff --git a/benchmark/bm_so_lists.rb b/benchmark/bm_so_lists.rb
index e8f4a2a5f..512e312cc 100644
--- a/benchmark/bm_so_lists.rb
+++ b/benchmark/bm_so_lists.rb
@@ -17,19 +17,19 @@ def test_lists()
# li2 must now be empty
# remove each individual item from right side of li3 and
# append to right side of li2 (reversing list)
- while (not li3.empty?)
+ until li3.empty?
li2.push(li3.pop)
end
# li3 must now be empty
# reverse li1 in place
li1.reverse!
# check that first item is now SIZE
- if li1[0] != SIZE then
+ if li1[0] != SIZE
p "not SIZE"
0
else
# compare li1 and li2 for equality
- if li1 != li2 then
+ if li1 != li2
return(0)
else
# return the length of the list