diff --git a/benchmarks.yml b/benchmarks.yml index 22bf2e43..8ce6f99a 100644 --- a/benchmarks.yml +++ b/benchmarks.yml @@ -119,6 +119,10 @@ respond_to: desc: respond_to tests the performance of the respond_to? method. category: micro single_file: true +object-new: + desc: instantiate a new object in a loop to test allocation performance + category: micro + single_file: true setivar: desc: setivar tests the performance of setting instance variable values. category: micro diff --git a/benchmarks/object-new.rb b/benchmarks/object-new.rb new file mode 100644 index 00000000..b079c393 --- /dev/null +++ b/benchmarks/object-new.rb @@ -0,0 +1,9 @@ +require_relative '../harness/loader' + +run_benchmark(100) do + i = 0 + while i < 1_000_000 + Object.new + i += 1 + end +end