diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-12-05 08:12:24 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-12-06 21:12:23 +0900 |
| commit | 856ae52021e2e75934f22158ff78a1adbd86ce22 (patch) | |
| tree | 1356e0dbe71d8d159dde9b68630b9190de006e9a /benchmark | |
| parent | e5810db1ad667c0c4aedce77a3643f64b20e1342 (diff) | |
| download | mruby-856ae52021e2e75934f22158ff78a1adbd86ce22.tar.gz mruby-856ae52021e2e75934f22158ff78a1adbd86ce22.zip | |
bm_ao_rendar.rb: use instance variables instead of class variables.
Class variables are slower than instance variables of classes.
Diffstat (limited to 'benchmark')
| -rw-r--r-- | benchmark/bm_ao_render.rb | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/benchmark/bm_ao_render.rb b/benchmark/bm_ao_render.rb index e55c34e09..77620cf07 100644 --- a/benchmark/bm_ao_render.rb +++ b/benchmark/bm_ao_render.rb @@ -12,18 +12,18 @@ NAO_SAMPLES = 8 module Rand # Use xorshift - @@x = 123456789 - @@y = 362436069 - @@z = 521288629 - @@w = 88675123 + @x = 123456789 + @y = 362436069 + @z = 521288629 + @w = 88675123 BNUM = 1 << 29 BNUMF = BNUM.to_f def self.rand - x = @@x + x = @x t = x ^ ((x & 0xfffff) << 11) - w = @@w - @@x, @@y, @@z = @@y, @@z, w - w = @@w = (w ^ (w >> 19) ^ (t ^ (t >> 8))) + w = @w + @x, @y, @z = @y, @z, w + w = @w = (w ^ (w >> 19) ^ (t ^ (t >> 8))) (w % BNUM) / BNUMF end end |
