Skip to content

Instantly share code, notes, and snippets.

@julien51
Created April 23, 2009 16:54
Show Gist options
  • Save julien51/100602 to your computer and use it in GitHub Desktop.
Save julien51/100602 to your computer and use it in GitHub Desktop.
require "rubygems"
require "nokogiri"
require "xmpp_parser.rb"
xml = <<-EOXML
<stream:features>
<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'>
<required/>
</starttls>
<mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>
<mechanism>DIGEST-MD5</mechanism>
<mechanism>PLAIN</mechanism>
</mechanisms>
</stream:features>
<proceed xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>
<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='DIGEST-MD5'/>
<message from='[email protected]' to='[email protected]' xml:lang='en'>
<body>Neither, fair saint, if either thee dislike.</body>
</message>
<iq type='set' from='[email protected]/blogbot' to='pubsub.shakespeare.lit' id='publish1'>
<pubsub xmlns='http://jabber.org/protocol/pubsub'>
<publish node='princely_musings'>
<item>
<entry xmlns='http://www.w3.org/2005/Atom'>
<title>Soliloquy</title>
<summary>
To be, or not to be: that is the question:
Whether 'tis nobler in the mind to suffer
The slings and arrows of outrageous fortune,
Or to take arms against a sea of troubles,
And by opposing end them?
</summary>
<link rel='alternate' type='text/html' href='http://denmark.lit/2003/12/13/atom03'/>
<id>tag:denmark.lit,2003:entry-32397</id>
<published>2003-12-13T18:30:02Z</published>
<updated>2003-12-13T18:30:02Z</updated>
</entry>
</item>
</publish>
</pubsub>
</iq>
EOXML
block = Proc.new { |node|
# puts "Node!"
}
@parser = Babylon::XmppParser.new(block)
@parser.push("<stream:stream
xmlns='jabber:client'
xmlns:stream='http://etherx.jabber.org/streams'
id='c2s_234'
from='example.com'
version='1.0'>")
new_mem = 0
loop do
pieces = rand(xml.size/50)
# So we have to pick 'pieces' number between 0 and string.size
indices = []
pieces.times do |i|
indices[i] = rand(xml.size)
end
# Now let's sort indices
indices.sort!
substrings = []
prev_index = 0
indices.each do |index|
substrings << xml[prev_index, (index-prev_index)]
prev_index = index
end
substrings << xml[prev_index, xml.size]
substrings.each do |s|
old_mem = new_mem
new_mem = `ps -o rss= -p #{Process.pid}`.to_i
if new_mem != old_mem
puts "REACHED NEW LEVEL : #{new_mem} at #{Time.now}"
end
@parser.push(s) # Reaches 20332 without the parser object. TO BE CONFIRMED THO
end
end
# Reaches levels... stops to grow for a while and starts growing again.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment