1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Make benchmark indentation consistent

Related to https://github.com/Shopify/yjit-bench/pull/109
This commit is contained in:
Takashi Kokubun 2022-08-19 14:42:50 -07:00
parent 745de85a7e
commit fc4acf8cae
No known key found for this signature in database
GPG key ID: 6FFC433B12EE23DD
2 changed files with 56 additions and 56 deletions

View file

@ -12,38 +12,38 @@ def _puts *args
end
class Planet
attr_accessor :x, :y, :z, :vx, :vy, :vz, :mass
attr_accessor :x, :y, :z, :vx, :vy, :vz, :mass
def initialize(x, y, z, vx, vy, vz, mass)
@x, @y, @z = x, y, z
@vx, @vy, @vz = vx * DAYS_PER_YEAR, vy * DAYS_PER_YEAR, vz * DAYS_PER_YEAR
@mass = mass * SOLAR_MASS
end
def move_from_i(bodies, nbodies, dt, i)
while i < nbodies
b2 = bodies[i]
dx = @x - b2.x
dy = @y - b2.y
dz = @z - b2.z
distance = Math.sqrt(dx * dx + dy * dy + dz * dz)
mag = dt / (distance * distance * distance)
b_mass_mag, b2_mass_mag = @mass * mag, b2.mass * mag
@vx -= dx * b2_mass_mag
@vy -= dy * b2_mass_mag
@vz -= dz * b2_mass_mag
b2.vx += dx * b_mass_mag
b2.vy += dy * b_mass_mag
b2.vz += dz * b_mass_mag
i += 1
def initialize(x, y, z, vx, vy, vz, mass)
@x, @y, @z = x, y, z
@vx, @vy, @vz = vx * DAYS_PER_YEAR, vy * DAYS_PER_YEAR, vz * DAYS_PER_YEAR
@mass = mass * SOLAR_MASS
end
@x += dt * @vx
@y += dt * @vy
@z += dt * @vz
end
def move_from_i(bodies, nbodies, dt, i)
while i < nbodies
b2 = bodies[i]
dx = @x - b2.x
dy = @y - b2.y
dz = @z - b2.z
distance = Math.sqrt(dx * dx + dy * dy + dz * dz)
mag = dt / (distance * distance * distance)
b_mass_mag, b2_mass_mag = @mass * mag, b2.mass * mag
@vx -= dx * b2_mass_mag
@vy -= dy * b2_mass_mag
@vz -= dz * b2_mass_mag
b2.vx += dx * b_mass_mag
b2.vy += dy * b_mass_mag
b2.vz += dz * b_mass_mag
i += 1
end
@x += dt * @vx
@y += dt * @vy
@z += dt * @vz
end
end
def energy(bodies)

View file

@ -1,33 +1,33 @@
prelude: |
class TheClass
def initialize
@v0 = 1
@v1 = 2
@v3 = 3
@levar = 1
end
def set_value_loop
# 1M
i = 0
while i < 1000000
# 10 times to de-emphasize loop overhead
@levar = i
@levar = i
@levar = i
@levar = i
@levar = i
@levar = i
@levar = i
@levar = i
@levar = i
@levar = i
i += 1
end
end
class TheClass
def initialize
@v0 = 1
@v1 = 2
@v3 = 3
@levar = 1
end
obj = TheClass.new
def set_value_loop
# 1M
i = 0
while i < 1000000
# 10 times to de-emphasize loop overhead
@levar = i
@levar = i
@levar = i
@levar = i
@levar = i
@levar = i
@levar = i
@levar = i
@levar = i
@levar = i
i += 1
end
end
end
obj = TheClass.new
benchmark:
vm_ivar_set_on_instance: |