daikon 0.8.1 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -26,3 +26,31 @@ require 'cucumber/rake/task'
26
26
  Cucumber::Rake::Task.new(:features)
27
27
 
28
28
  task :default => :spec
29
+
30
+ def parse_monitor
31
+ monitor = Daikon::Monitor.new(nil, nil)
32
+
33
+ File.open("monitor.log", "r") do |f|
34
+ until f.eof?
35
+ monitor.parse(f.readline)
36
+ end
37
+ end
38
+ end
39
+
40
+ desc "benchmark monitor.log against the monitor parsing"
41
+ task :bench do
42
+ require 'benchmark'
43
+ Benchmark.bm do |bm|
44
+ bm.report do
45
+ parse_monitor
46
+ end
47
+ end
48
+ end
49
+
50
+ desc "perf tools the monitor.log"
51
+ task :perf do
52
+ require 'perftools'
53
+ PerfTools::CpuProfiler.start("daikon.profile") do
54
+ parse_monitor
55
+ end
56
+ end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{daikon}
8
- s.version = "0.8.1"
8
+ s.version = "0.8.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Nick Quaranto"]
12
- s.date = %q{2011-03-17}
12
+ s.date = %q{2011-03-22}
13
13
  s.default_executable = %q{daikon}
14
14
  s.description = %q{daikon, a radishapp.com client}
15
15
  s.email = %q{nick@quaran.to}
@@ -27,5 +27,5 @@ require 'daikon/daemons_hacks'
27
27
  require 'daikon/redis_hacks'
28
28
 
29
29
  module Daikon
30
- VERSION = "0.8.1"
30
+ VERSION = "0.8.2"
31
31
  end
@@ -8,7 +8,7 @@ module Daikon
8
8
  OTHER_COMMANDS = ["AUTH", "BGREWRITEAOF", "BGSAVE", "CONFIG GET", "CONFIG SET", "CONFIG RESETSTAT", "DBSIZE", "DEBUG OBJECT", "DEBUG SEGFAULT", "DISCARD", "ECHO", "EXEC", "FLUSHALL", "FLUSHDB", "INFO", "LASTSAVE", "MONITOR", "MULTI", "PING", "PSUBSCRIBE", "PUBLISH", "PUNSUBSCRIBE", "QUIT", "RANDOMKEY", "SAVE", "SELECT", "SHUTDOWN", "SUBSCRIBE", "SYNC", "UNSUBSCRIBE", "UNWATCH", "WATCH"].to_set
9
9
  ALL_COMMANDS = READ_COMMANDS + WRITE_COMMANDS + OTHER_COMMANDS
10
10
 
11
- NEW_FORMAT = /^\+?(\d+\.\d+)( "[A-Z]+".*)/i
11
+ NEW_FORMAT = /^\+?\d+\.\d+ "(.*)"$/i
12
12
  OLD_SINGLE_FORMAT = /^(#{NO_ARG_COMMANDS.join('|')})$/i
13
13
  OLD_MORE_FORMAT = /^[A-Z]+ .*$/i
14
14
 
@@ -50,14 +50,14 @@ module Daikon
50
50
 
51
51
  def parse(line)
52
52
  if line =~ NEW_FORMAT
53
- push($2)
53
+ push($1.split('" "'))
54
54
  elsif line =~ OLD_SINGLE_FORMAT || line =~ OLD_MORE_FORMAT
55
- push(line)
55
+ push(line.split)
56
56
  end
57
57
  end
58
58
 
59
- def push(raw_command)
60
- command, key, *rest = raw_command.strip.gsub('"', '').split
59
+ def push(split_command)
60
+ command, key, *rest = split_command
61
61
  command.upcase!
62
62
 
63
63
  return unless ALL_COMMANDS.member?(command)
@@ -66,6 +66,9 @@ module Daikon
66
66
  incr_command(command)
67
67
  incr_total(command)
68
68
  if key
69
+ key.gsub!(".", "{PERIOD}") if key.include?('.')
70
+ key.gsub!("$", "{DOLLAR}") if key.include?('$')
71
+
69
72
  incr_key(key)
70
73
  incr_namespace(key)
71
74
  else
@@ -75,9 +78,8 @@ module Daikon
75
78
  end
76
79
 
77
80
  def incr_namespace(key)
78
- namespace, has_namespace = key.split(/(?::|-)/, 2)
79
- if has_namespace
80
- data["namespaces"][namespace] += 1
81
+ if marker = key =~ /:|-/
82
+ data["namespaces"][key[0...marker]] += 1
81
83
  else
82
84
  incr_global_namespace
83
85
  end
@@ -92,7 +94,7 @@ module Daikon
92
94
  end
93
95
 
94
96
  def incr_key(key)
95
- data["keys"][key.gsub(".", "{PERIOD}").gsub("$", "{DOLLAR}")] += 1
97
+ data["keys"][key] += 1
96
98
  end
97
99
 
98
100
  def incr_total(command)
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: daikon
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.8.1
5
+ version: 0.8.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Nick Quaranto
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-03-17 00:00:00 -06:00
13
+ date: 2011-03-22 00:00:00 -04:00
14
14
  default_executable: daikon
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency