在ubuntu 10.10上运行ruby脚本时性能严重下降
当我在ubuntu(10.10)上运行ruby脚本时,它会严重降低我的计算机性能(达到需要重新启动的程度)。即使我停止脚本,它也不会改进。而同样的脚本在windows上运行数小时后仍然可以正常运行,对计算机性能没有任何明显的影响 我目前正在使用ruby 1.8.7。我查了一下谷歌,但没用 可能的原因是什么 PS:这只是聊天客户端的一个玩具脚本,所以需要定期将数据传输到google聊天服务器 编辑;守则:在ubuntu 10.10上运行ruby脚本时性能严重下降,ruby,Ruby,当我在ubuntu(10.10)上运行ruby脚本时,它会严重降低我的计算机性能(达到需要重新启动的程度)。即使我停止脚本,它也不会改进。而同样的脚本在windows上运行数小时后仍然可以正常运行,对计算机性能没有任何明显的影响 我目前正在使用ruby 1.8.7。我查了一下谷歌,但没用 可能的原因是什么 PS:这只是聊天客户端的一个玩具脚本,所以需要定期将数据传输到google聊天服务器 编辑;守则: require 'rubygems' require 'xmpp4r-simple' use
require 'rubygems'
require 'xmpp4r-simple'
username = 'username' #your username here
password = 'password'
answer='ai'
#to_username = gets #prompt will wait for
$i=1
$cap=1
puts "Connecting to jabber server.."
jabber = Jabber::Simple.new(username+'@gmail.com',password)
jabber.status(:dnd,"status")
puts "Connected."
while $cap!=0 do
jabber.received_messages do |msg|
$cap=0
jabber.deliver(msg.from.node+"@gmail.com","You have to pass a captcha test to talk to me.(Its a hard one)Networking==OS then POM==?")
end
end
while $i!=0 do
jabber.received_messages do |msg|
if msg.body.downcase != answer then
message="sorry you failed the captcha try again...(Its a hard one) Networking==OS then POM==??"
jabber.deliver(msg.from.node+"@gmail.com",message)
else
$i=0
jabber.deliver(msg.from.node+"@gmail.com","You passed the captcha.You are entitled to talk to me")
puts msg.from.node
puts "Passed the captcha"
puts "=================="
puts msg
puts "=================="
end
end
end
#$i=0
while (true) do
jabber.received_messages do |msg|
puts "=============================================="
puts msg.body
puts "----------------------------------------------"
message=gets
#$i=1;
jabber.deliver(msg.from.node+"@gmail.com", message)
#end
#end
end
end
这只是一个原型代码。我知道如果在程序的生命周期内有多人聊天,代码将不会以预期的方式运行。此外,除了杀死脚本之外,没有其他方法可以阻止它。如果你发布代码,它会有一点点帮助:)@JensTinfors我也发布了代码。。。