lib/memdump/memory_dump.rb
# Get a random sample of the records
#
# The sampling is random, so the returned set might be bigger or smaller
# than expected. Do not use on small sets.
#
# @param [Float] the ratio of selected samples vs. total samples (0.1
#   will select approximately 10% of the samples)
Get a random sample of the records
The sampling is random, so the returned set might be bigger or smaller
than expected. Do not use on small sets.
Get a random sample of the records The sampling is random so the returned set might be bigger or smaller than expected . Do not use on small sets .
def sample(ratio)
            result = Hash.new
            each_record do |record|
                if rand <= ratio
                    result[record['address']] = record
                end
            end
            MemoryDump.new(result)
        end
def sample ( ratio ) result = Hash . new each_record do | record | if rand <= ratio result [ record [ 'address' ] ] = record end end MemoryDump . new ( result ) end
Get a random sample of the records
The sampling is random, so the returned set might be bigger or smaller
than expected.
Get a random sample of the records The sampling is random so the returned set might be bigger or smaller than expected .
ratio
the ratio of selected samples vs. total samples (0.1 will select approximately 10% of the samples)
the ratio of selected samples vs . total samples ( 0 . 1 will select approximately 10% of the samples )