Skip to content

Commit 68877f6

Browse files
committed
Use a fiber-local instead of a class variable in BenchmarkInterface::BenchmarkSet
* This avoids sharing the BenchmarkSet and also all benchmarks blocks. Sharing the benchmark data passed to the benchmark block should be avoided.
1 parent 270ddce commit 68877f6

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

bench/benchmark-interface/lib/benchmark-interface/benchmark-set.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class BenchmarkSet
1414
def initialize
1515
@benchmarks = []
1616
@counter = 0
17-
@@current = self
17+
Thread.current[:benchmark_interface_benchmark_set] = self
1818
@iterations = 1
1919
end
2020

@@ -81,10 +81,8 @@ def benchmark(name)
8181
benchmarks([name]).first
8282
end
8383

84-
@@current = nil
85-
8684
def self.current
87-
@@current
85+
Thread.current[:benchmark_interface_benchmark_set]
8886
end
8987

9088
end

0 commit comments

Comments
 (0)