benchmark_client

in benchmark/gem.rb [114:141]


    def benchmark_client(legacy_report_data, report_data)
      return unless client_module_name

      memory = Benchmark.fork_run do |out|
        require gem_name
        client_klass = Kernel.const_get(client_module_name).const_get(:Client)
        unless defined?(JRUBY_VERSION)
          r = ::MemoryProfiler.report { client_klass.new(stub_responses: true) }
          out[:client_mem_retained] = r.total_retained_memsize / (1024.0 * 1024.0)
          out[:client_mem_allocated] = r.total_allocated_memsize / (1024.0 * 1024.0)
        end
      end

      legacy_report_data.merge!(memory)

      report_data << Result.new(
        "#{service_name(gem_name)}.client.retained.size",
        "The amount of memory retained when creating the #{service_name(gem_name)} client.",
        [memory[:client_mem_retained]]
      ).format

      report_data << Result.new(
        "#{service_name(gem_name)}.client.allocated.size",
        "The amount of memory allocated when creating the #{service_name(gem_name)} client.",
        [memory[:client_mem_allocated]]
      ).format
    end