Skip to content

Instantly share code, notes, and snippets.

@SamSaffron
Last active December 20, 2016 22:31
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SamSaffron/b8e06a9873034575dacef82f4123a604 to your computer and use it in GitHub Desktop.
Save SamSaffron/b8e06a9873034575dacef82f4123a604 to your computer and use it in GitHub Desktop.
@preallocate = []
500_000.times do
@preallocate << ""
end
def process_request
allocate = rand(80_000) + 20000
req = []
allocate.times do
req << " " * rand(1000)
end
end
def stats(i)
puts "Heap length: #{GC.stat[:heap_sorted_length]} iterations: #{i} slots #{GC.stat[:heap_available_slots]} GC counts: #{GC.stat[:minor_gc_count]}/#{GC.stat[:major_gc_count]} old_objects #{GC.stat[:old_objects]}"
end
i = 0
@heap_length = GC.stat[:heap_sorted_length]
stats(0)
while true
i += 1
process_request
#GC.start(full_mark: true)
if @heap_length < GC.stat[:heap_sorted_length]
@heap_length = GC.stat[:heap_sorted_length]
stats(i)
end
end
@funny-falcon
Copy link

@SamSaffron
Copy link
Author

good point, I should fix that @funny-falcon , I actually want to generate data that looks more like a real request, so I should get a more accurate sampling of a real req and then regenerate that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment