Sha256: f7a71b357422462c75837ffe4ef7bfa94f784cb7f6e5a5c114c0dcb389748710

Contents?: true

Size: 861 Bytes

Versions: 2

Compression:

Stored size: 861 Bytes

Contents

# Copyright 2013 Google Inc. All Rights Reserved.
# Licensed under the Apache License, Version 2.0, found in the LICENSE file.

require_relative "../lib/allocation_stats"
require "yaml"
require "yajl"
require "pry"

if RbConfig::CONFIG["MAJOR"].to_i < 2 || RbConfig::CONFIG["MINOR"].to_i < 1
  warn "Error: AllocationStats requires Ruby 2.1 or greater"
  exit 1
end

def allocate_a_string_from_spec_helper
  return "a string from spec_helper"
end

class MyClass
  def my_method
    @new_hash = {0 => "foo", 1 => "bar"}
  end

  MY_METHOD_BODY_LINE = __LINE__ - 3

  # This method allocates a different number of objects each call:
  # 1st call: 1x Array, 1x String
  # 2nd call;           2x Strings
  # 3rd call;           4x Strings
  # 4th call;           8x Strings
  def memoizing_method
    @c ||= []

    (@c.size + 1).times { @c << "string" }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
allocation_stats-0.1.2 spec/spec_helper.rb
allocation_stats-0.1.1 spec/spec_helper.rb