Browse files

memprof output

  • Loading branch information...
1 parent 46ece6e commit 98cbf4cecc3f8b17bf515a6988734d8312fa4f48 @winton committed Apr 29, 2011
Showing with 10 additions and 2 deletions.
  1. +1 −0 config/gemsets.yml
  2. +1 −0 config/gemspec.yml
  3. +1 −0 lib/puggernaut.rb
  4. +3 −1 lib/puggernaut/server.rb
  5. +2 −0 lib/puggernaut/server/http.rb
  6. +2 −1 public/puggernaut.js
View
1 config/gemsets.yml
@@ -1,6 +1,7 @@
puggernaut:
em-websocket: ~>0.2.1
eventmachine: ~>0.12.10
+ memprof: ~>0.3.10
rake: >=0.8.7
rspec: ~>1.0
sinatra: ~>1.1.0
View
1 config/gemspec.yml
@@ -9,4 +9,5 @@ description: Simple server push implementation using eventmachine and long polli
dependencies:
- em-websocket
- eventmachine
+ - memprof
development_dependencies: null
View
1 lib/puggernaut.rb
@@ -4,6 +4,7 @@
require 'eventmachine'
require 'em-websocket'
+require 'memprof'
$:.unshift File.dirname(__FILE__)
View
4 lib/puggernaut/server.rb
@@ -14,8 +14,8 @@ def initialize(http_port=8100, tcp_port=http_port.to_i+1, ws_port=tcp_port.to_i+
puts "*snort*\n\n"
begin
+ Memprof.start
Channel.channels = []
- GC.start
EM.epoll if EM.epoll?
EM.run do
logger.info "Server#initialize - Starting HTTP - #{http_port}"
@@ -29,6 +29,8 @@ def initialize(http_port=8100, tcp_port=http_port.to_i+1, ws_port=tcp_port.to_i+
errors = 0
end
+ Memprof.stats(Dir.pwd + '/log/puggernaut.mem.log')
+ Memprof.stop
rescue Interrupt
logger.info "Server#initialize - Shutting down"
exit
View
2 lib/puggernaut/server/http.rb
@@ -21,6 +21,8 @@ def receive_data(data)
logger.info "Server::Http#receive_data - Request - #{path} - #{query}"
query = CGI.parse(query) if not query.nil?
end
+
+ puts path
if path == '/'
channels, @join_leave, lasts, time, user_id = query_defaults(query)
View
3 public/puggernaut.js
@@ -4,6 +4,7 @@ var Puggernaut = new function() {
var self = this;
this.disabled = false;
+ this.host = window.location.host;
this.path = '/long_poll';
this.port = 8102;
this.inhabitants = inhabitants;
@@ -189,7 +190,7 @@ var Puggernaut = new function() {
function websocket(join_leave, time, user_id) {
if (channelLength() > 0 && !self.disabled && errors <= 10) {
started = true;
- request = new WebSocket("ws://" + window.location.host + ":" + self.port + "/");
+ request = new WebSocket("ws://" + self.host + ":" + self.port + "/");
request.onopen = function() {
errors = 0;
if (started)

0 comments on commit 98cbf4c

Please sign in to comment.