Last active
December 20, 2016 22:31
-
-
Save SamSaffron/b8e06a9873034575dacef82f4123a604 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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 |
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
https://gist.github.com/SamSaffron/b8e06a9873034575dacef82f4123a604#file-heap_bloater-rb-L12
Did you intend
req << " " * rand(1000)
?