benelux 0.3.0.002 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGES.txt +8 -0
- data/benelux.gemspec +1 -1
- data/lib/benelux.rb +1 -1
- data/lib/benelux/stats.rb +12 -7
- data/lib/benelux/tags.rb +21 -15
- data/lib/benelux/timeline.rb +1 -1
- metadata +2 -2
data/CHANGES.txt
CHANGED
@@ -1,6 +1,14 @@
|
|
1
1
|
BENELUX, CHANGES
|
2
2
|
|
3
3
|
|
4
|
+
#### 0.3.2 (2009-10-02) ###############################
|
5
|
+
|
6
|
+
* CHANGE: Major performance improvement.
|
7
|
+
|
8
|
+
#### 0.3.1 (2009-09-30) ###############################
|
9
|
+
|
10
|
+
* FIXED: Rubygems versioning issue.
|
11
|
+
|
4
12
|
#### 0.3.0 (2009-09-30) ###############################
|
5
13
|
|
6
14
|
Initial public release
|
data/benelux.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
@spec = Gem::Specification.new do |s|
|
2
2
|
s.name = "benelux"
|
3
3
|
s.rubyforge_project = 'benelux'
|
4
|
-
s.version = "0.3.
|
4
|
+
s.version = "0.3.2"
|
5
5
|
s.summary = "Benelux: Little freakin' timers for your Ruby codes"
|
6
6
|
s.description = s.summary
|
7
7
|
s.author = "Delano Mandelbaum"
|
data/lib/benelux.rb
CHANGED
data/lib/benelux/stats.rb
CHANGED
@@ -82,8 +82,8 @@ module Benelux
|
|
82
82
|
def sd() merge.sd end
|
83
83
|
def n() merge.n end
|
84
84
|
|
85
|
-
def merge(
|
86
|
-
tags = Benelux::TagHelpers.normalize tags
|
85
|
+
def merge(tags={})
|
86
|
+
# tags = Benelux::TagHelpers.normalize tags
|
87
87
|
mc = Calculator.new
|
88
88
|
all = tags.empty? ? self : self.filter(tags)
|
89
89
|
all.each { |calc|
|
@@ -93,8 +93,8 @@ module Benelux
|
|
93
93
|
mc
|
94
94
|
end
|
95
95
|
|
96
|
-
def [](
|
97
|
-
tags = Benelux::TagHelpers.normalize tags
|
96
|
+
def [](tags={})
|
97
|
+
# tags = Benelux::TagHelpers.normalize tags
|
98
98
|
g = Benelux::Stats::Group.new @name
|
99
99
|
g << self.select { |c| c.tags >= tags }
|
100
100
|
g.flatten!(1) # only 1 level deep
|
@@ -152,16 +152,21 @@ module Benelux
|
|
152
152
|
|
153
153
|
# Dump this Stats object with an optional additional message.
|
154
154
|
def dump(msg = "", out=STDERR)
|
155
|
-
out.puts "#{msg}: #{self.
|
155
|
+
out.puts "#{msg}: #{self.report}"
|
156
156
|
end
|
157
157
|
|
158
158
|
# Returns a common display (used by dump)
|
159
|
-
def
|
159
|
+
def report
|
160
160
|
v = [mean, @n, @sum, @sumsq, sd, @min, @max]
|
161
161
|
t = %q'%8d(N) %10.4f(SUM) %8.4f(SUMSQ) %8.4f(SD) %8.4f(MIN) %8.4f(MAX)'
|
162
162
|
('%0.4f: ' << t) % v
|
163
163
|
end
|
164
|
-
|
164
|
+
|
165
|
+
def inspect
|
166
|
+
v = [ mean, @n, @sum, @sumsq, sd, @min, @max, tags]
|
167
|
+
"%.4f: n=%.4f sum=%.4f sumsq=%.4f sd=%.4f min=%.4f max=%.4f %s" % v
|
168
|
+
end
|
169
|
+
|
165
170
|
def to_s; mean.to_s; end
|
166
171
|
def to_f; mean.to_f; end
|
167
172
|
def to_i; mean.to_i; end
|
data/lib/benelux/tags.rb
CHANGED
@@ -66,8 +66,8 @@ module Benelux
|
|
66
66
|
to_s
|
67
67
|
end
|
68
68
|
|
69
|
-
def ==(
|
70
|
-
other = Benelux::TagHelpers.normalize other
|
69
|
+
def ==(other)
|
70
|
+
# other = Benelux::TagHelpers.normalize other
|
71
71
|
if other.is_a?(Array)
|
72
72
|
(self.values & other).sort == other.sort
|
73
73
|
else
|
@@ -86,25 +86,31 @@ module Benelux
|
|
86
86
|
# a >= [2, 1] # => true
|
87
87
|
# a > [2, 1] # => false
|
88
88
|
#
|
89
|
-
def <=>(
|
90
|
-
other = Benelux::TagHelpers.normalize other
|
91
|
-
return 0 if self ==
|
92
|
-
|
93
|
-
return -1 unless (self.values & other).size >= other.size
|
94
|
-
else
|
95
|
-
return -1 unless (self.keys & other.keys).size >= other.keys.size
|
96
|
-
other.each_pair { |n,v|
|
97
|
-
return -1 unless self.has_key?(n) && self[n] == v
|
98
|
-
}
|
99
|
-
end
|
100
|
-
1
|
89
|
+
def <=>(b)
|
90
|
+
#other = Benelux::TagHelpers.normalize other
|
91
|
+
return 0 if self == b
|
92
|
+
self.send :"compare_#{b.class}", b
|
101
93
|
end
|
102
|
-
|
94
|
+
|
103
95
|
def >(other) (self <=> other) > 0 end
|
104
96
|
def <(other) (self <=> other) < 0 end
|
105
97
|
|
106
98
|
def <=(other) (self <=> other) <= 0 end
|
107
99
|
def >=(other) (self <=> other) >= 0 end
|
100
|
+
|
101
|
+
private
|
102
|
+
|
103
|
+
def compare_Hash(b)
|
104
|
+
a = self
|
105
|
+
return -1 unless (a.values_at(*b.keys) & b.values).size >= b.size
|
106
|
+
1
|
107
|
+
end
|
108
|
+
alias_method :"compare_Benelux::Tags", :compare_Hash
|
109
|
+
|
110
|
+
def compare_Array(b)
|
111
|
+
return -1 unless (self.values & b).size >= b.size
|
112
|
+
1
|
113
|
+
end
|
108
114
|
|
109
115
|
end
|
110
116
|
end
|
data/lib/benelux/timeline.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: benelux
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Delano Mandelbaum
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-10-
|
12
|
+
date: 2009-10-02 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|