benelux 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES.txt +10 -0
- data/benelux.gemspec +1 -3
- data/lib/benelux.rb +67 -9
- data/lib/benelux/mixins/thread.rb +7 -0
- data/lib/benelux/stats.rb +4 -0
- data/lib/benelux/timeline.rb +5 -1
- data/tryouts/20_tracks_tryouts.rb +0 -84
- metadata +3 -5
- data/lib/benelux/count.rb +0 -29
- data/tryouts/12_selectable_global_tryouts.rb +0 -23
data/CHANGES.txt
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
BENELUX, CHANGES
|
2
2
|
|
3
|
+
#### 0.5.1 (2009-10-29) ###############################
|
4
|
+
|
5
|
+
* FIXED: Timeline#clear
|
6
|
+
* ADDED: Thread#rotate_timeline
|
7
|
+
* ADDED: Stats#clear
|
8
|
+
|
9
|
+
|
10
|
+
#### 0.5.0 (2009-10-21) ###############################
|
11
|
+
|
12
|
+
* CHANGE: Do not use global timeline, update from dead threads.
|
3
13
|
|
4
14
|
#### 0.4.4 (2009-10-20) ###############################
|
5
15
|
|
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.5.
|
4
|
+
s.version = "0.5.1"
|
5
5
|
s.summary = "Benelux: Little freakin' timers for your Ruby codes"
|
6
6
|
s.description = s.summary
|
7
7
|
s.author = "Delano Mandelbaum"
|
@@ -24,7 +24,6 @@
|
|
24
24
|
Rakefile
|
25
25
|
benelux.gemspec
|
26
26
|
lib/benelux.rb
|
27
|
-
lib/benelux/count.rb
|
28
27
|
lib/benelux/mark.rb
|
29
28
|
lib/benelux/mixins/symbol.rb
|
30
29
|
lib/benelux/mixins/thread.rb
|
@@ -40,7 +39,6 @@
|
|
40
39
|
lib/selectable/tags.rb
|
41
40
|
tryouts/10_stats_tryouts.rb
|
42
41
|
tryouts/11_selectable_tryouts.rb
|
43
|
-
tryouts/12_selectable_global_tryouts.rb
|
44
42
|
tryouts/20_tracks_tryouts.rb
|
45
43
|
tryouts/30_reporter_tryouts.rb
|
46
44
|
tryouts/30_timeline_tryouts.rb
|
data/lib/benelux.rb
CHANGED
@@ -5,7 +5,7 @@ require 'thwait'
|
|
5
5
|
require 'selectable'
|
6
6
|
|
7
7
|
module Benelux
|
8
|
-
VERSION = "0.5.
|
8
|
+
VERSION = "0.5.1"
|
9
9
|
NOTSUPPORTED = [Class, Object, Kernel]
|
10
10
|
|
11
11
|
class BeneluxError < RuntimeError; end
|
@@ -15,7 +15,6 @@ module Benelux
|
|
15
15
|
class BadRecursion < BeneluxError; end
|
16
16
|
|
17
17
|
require 'benelux/mark'
|
18
|
-
require 'benelux/count'
|
19
18
|
require 'benelux/track'
|
20
19
|
require 'benelux/range'
|
21
20
|
require 'benelux/stats'
|
@@ -65,8 +64,9 @@ module Benelux
|
|
65
64
|
name = Thread.current.track_name
|
66
65
|
else
|
67
66
|
Thread.current.track_name = name
|
68
|
-
Thread.current.timeline ||= Benelux::Timeline.new
|
69
67
|
@@mutex.synchronize do
|
68
|
+
Thread.current.timeline ||= Benelux::Timeline.new
|
69
|
+
Thread.current.rotated_timelines ||= []
|
70
70
|
@tracks[name] ||= Track.new(name, group)
|
71
71
|
@tracks[name].add_thread Thread.current
|
72
72
|
@known_threads << Thread.current
|
@@ -78,12 +78,26 @@ module Benelux
|
|
78
78
|
|
79
79
|
# Only updates data from threads that are dead
|
80
80
|
def Benelux.update_global_timeline
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
81
|
+
@@mutex.synchronize do
|
82
|
+
dthreads = Benelux.known_threads.select { |t|
|
83
|
+
!t.timeline.nil? && (t.nil? || !t.status)
|
84
|
+
}
|
85
|
+
# Threads that have rotated timelines
|
86
|
+
rthreads = Benelux.known_threads.select { |t|
|
87
|
+
!t.rotated_timelines.empty?
|
88
|
+
}
|
89
|
+
dtimelines = dthreads.collect { |t| t.timeline }
|
90
|
+
# Also get all rotated timelines.
|
91
|
+
rthreads.each { |t|
|
92
|
+
# We loop carefully through the rotated timelines
|
93
|
+
# incase something was added while we're working.
|
94
|
+
while !t.rotated_timelines.empty?
|
95
|
+
dtimelines.push t.rotated_timelines.shift
|
96
|
+
end
|
97
|
+
}
|
98
|
+
tl = Benelux.timeline.merge! *dtimelines
|
99
|
+
tl
|
100
|
+
end
|
87
101
|
end
|
88
102
|
|
89
103
|
# Thread tags become the default for any new Mark or Range.
|
@@ -149,6 +163,50 @@ end
|
|
149
163
|
|
150
164
|
|
151
165
|
__END__
|
166
|
+
0.5.0:
|
167
|
+
ruby -rprofile bin/stella generate -p examples/essentials/plan.rb -c 200 -d 2m localhost:3114
|
168
|
+
Summary:
|
169
|
+
max clients: 200
|
170
|
+
repetitions: 9
|
171
|
+
test time: 117.97s
|
172
|
+
post time: 156.50s
|
173
|
+
|
174
|
+
% cumulative self self total
|
175
|
+
time seconds seconds calls ms/call ms/call name
|
176
|
+
32.38 71.88 71.88 200 359.40 359.40 Thread#join
|
177
|
+
9.63 93.25 21.37 166149 0.13 0.20 Selectable::Tags#==
|
178
|
+
8.79 112.77 19.52 166149 0.12 0.69 Selectable::Tags#>=
|
179
|
+
8.42 131.47 18.70 170598 0.11 0.31 Kernel.send
|
180
|
+
4.38 141.19 9.72 166149 0.06 0.39 Selectable::Tags#<=>
|
181
|
+
4.31 150.75 9.56 50641 0.19 0.25 Benelux::Stats::Calculator#merge!
|
182
|
+
3.74 159.06 8.31 296362 0.03 0.03 Hash#values
|
183
|
+
3.03 165.78 6.72 556828 0.01 0.01 Array#size
|
184
|
+
2.61 171.57 5.79 166150 0.03 0.05 Array#&
|
185
|
+
2.25 176.57 5.00 36169 0.14 0.28 Selectable::Tags#compare_Array
|
186
|
+
1.56 180.04 3.47 332505 0.01 0.01 Fixnum#>=
|
187
|
+
1.53 183.44 3.40 4224 0.80 26.52 Array#each
|
188
|
+
1.32 186.37 2.93 166476 0.02 0.02 Kernel.is_a?
|
189
|
+
0.96 188.50 2.13 172011 0.01 0.01 Kernel.class
|
190
|
+
0.84 190.36 1.86 50641 0.04 0.05 Selectable::Object.add_tags_quick
|
191
|
+
0.83 192.21 1.85 14466 0.13 0.17 Selectable::Tags#compare_Hash
|
192
|
+
0.80 193.98 1.77 170551 0.01 0.01 Module#to_s
|
193
|
+
0.79 195.73 1.75 152534 0.01 0.01 Float#+
|
194
|
+
0.71 197.31 1.58 166192 0.01 0.01 String#intern
|
195
|
+
0.64 198.74 1.43 54292 0.03 0.03 Numeric#eql?
|
196
|
+
0.63 200.14 1.40 83392 0.02 0.02 String#eql?
|
197
|
+
0.53 201.31 1.17 130778 0.01 0.01 Fixnum#==
|
198
|
+
0.35 202.09 0.78 7310 0.11 0.15 Enumerable.member?
|
199
|
+
0.32 202.81 0.72 35940 0.02 0.02 Hash#==
|
200
|
+
0.30 203.48 0.67 201 3.33 6.37 Thread#new
|
201
|
+
0.29 204.12 0.64 11 58.18 70.00 Array#collect
|
202
|
+
0.27 204.73 0.61 35940 0.02 0.02 Hash#size
|
203
|
+
0.27 205.34 0.61 201 3.03 3.03 Thread#initialize
|
204
|
+
0.21 205.80 0.46 13901 0.03 0.03 Fixnum#>
|
205
|
+
0.21 206.26 0.46 202 2.28 7.08 Kernel.require
|
206
|
+
0.20 206.70 0.44 50681 0.01 0.01 Hash#merge!
|
207
|
+
0.16 207.05 0.35 2666 0.13 0.13 Array#push
|
208
|
+
|
209
|
+
0.4.2 and Earlier:
|
152
210
|
% cumulative self self total
|
153
211
|
time seconds seconds calls ms/call ms/call name
|
154
212
|
33.04 40.39 40.39 832483 0.05 0.10 Selectable::Tags#==
|
data/lib/benelux/stats.rb
CHANGED
data/lib/benelux/timeline.rb
CHANGED
@@ -19,7 +19,6 @@ module Benelux
|
|
19
19
|
#
|
20
20
|
class Timeline < Array
|
21
21
|
include Selectable
|
22
|
-
|
23
22
|
attr_accessor :ranges
|
24
23
|
attr_accessor :stats
|
25
24
|
attr_accessor :default_tags
|
@@ -44,6 +43,10 @@ module Benelux
|
|
44
43
|
@default_tags[:track]
|
45
44
|
end
|
46
45
|
|
46
|
+
def dump
|
47
|
+
|
48
|
+
end
|
49
|
+
|
47
50
|
def duration
|
48
51
|
self.last - self.first
|
49
52
|
end
|
@@ -120,6 +123,7 @@ module Benelux
|
|
120
123
|
|
121
124
|
def clear
|
122
125
|
@ranges.clear
|
126
|
+
@stats.clear
|
123
127
|
super
|
124
128
|
end
|
125
129
|
|
@@ -20,87 +20,3 @@ tryouts "Tracks" do
|
|
20
20
|
end
|
21
21
|
|
22
22
|
end
|
23
|
-
|
24
|
-
__END__
|
25
|
-
# OLD (0.3):
|
26
|
-
|
27
|
-
tryouts "Essentials" do
|
28
|
-
|
29
|
-
setup do
|
30
|
-
class ::Sleeper
|
31
|
-
def do_something() sleep rand/3 end
|
32
|
-
def another_method(t) t*2 end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
drill "Add timers to existing objects", true do
|
37
|
-
Benelux.add_timer Sleeper, :do_something
|
38
|
-
Sleeper.new.respond_to? :timeline
|
39
|
-
end
|
40
|
-
|
41
|
-
dream :class, SelectableArray
|
42
|
-
dream :size, 1
|
43
|
-
dream :proc, lambda { |obj|
|
44
|
-
pm = obj.first
|
45
|
-
pm.class == Benelux::MethodTimer &&
|
46
|
-
pm.meth == :do_something &&
|
47
|
-
pm.klass == Sleeper
|
48
|
-
}
|
49
|
-
drill "Keeps a list of modified methods" do
|
50
|
-
Benelux.packed_methods
|
51
|
-
end
|
52
|
-
|
53
|
-
drill "Knows what a timer has been defined", true do
|
54
|
-
Benelux.timed_method? :Sleeper, :do_something
|
55
|
-
end
|
56
|
-
|
57
|
-
drill "Knows what a timer has not been defined", false do
|
58
|
-
Benelux.timed_method? :Sleeper, :no_such_method
|
59
|
-
end
|
60
|
-
|
61
|
-
dream :class, SelectableArray
|
62
|
-
drill "A Benelux object has a timed_methods method" do
|
63
|
-
s = Sleeper.new
|
64
|
-
s.do_something
|
65
|
-
s.timed_methods
|
66
|
-
end
|
67
|
-
|
68
|
-
end
|
69
|
-
|
70
|
-
tryouts "Counters" do
|
71
|
-
setup do
|
72
|
-
class ::Sleeper
|
73
|
-
def do_something() sleep rand/3 end
|
74
|
-
def another_method(t) t*2 end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
drill "Add timers to existing objects", true do
|
78
|
-
Benelux.add_counter Sleeper, :another_method do |args,ret|
|
79
|
-
ret
|
80
|
-
end
|
81
|
-
Sleeper.new.respond_to? :timeline
|
82
|
-
end
|
83
|
-
dream :kind_of?, Benelux::MethodPacker
|
84
|
-
drill "Can get specific packed method" do
|
85
|
-
Benelux.packed_method Sleeper, :another_method
|
86
|
-
end
|
87
|
-
|
88
|
-
dream :class, Benelux::Count
|
89
|
-
dream :name, :another_method
|
90
|
-
dream :to_i, 2000
|
91
|
-
drill "Run counter" do
|
92
|
-
a = Sleeper.new
|
93
|
-
a.another_method(1000)
|
94
|
-
pm = Benelux.packed_method Sleeper, :another_method
|
95
|
-
Benelux.thread_timeline.counts.first
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
xtryouts "Not supported" do
|
100
|
-
|
101
|
-
dream :exception, Benelux::NotSupported
|
102
|
-
drill "Class is not supported" do
|
103
|
-
Benelux.add_timer Class, :new
|
104
|
-
end
|
105
|
-
|
106
|
-
end
|
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.5.
|
4
|
+
version: 0.5.1
|
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-29 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -39,7 +39,6 @@ files:
|
|
39
39
|
- Rakefile
|
40
40
|
- benelux.gemspec
|
41
41
|
- lib/benelux.rb
|
42
|
-
- lib/benelux/count.rb
|
43
42
|
- lib/benelux/mark.rb
|
44
43
|
- lib/benelux/mixins/symbol.rb
|
45
44
|
- lib/benelux/mixins/thread.rb
|
@@ -55,7 +54,6 @@ files:
|
|
55
54
|
- lib/selectable/tags.rb
|
56
55
|
- tryouts/10_stats_tryouts.rb
|
57
56
|
- tryouts/11_selectable_tryouts.rb
|
58
|
-
- tryouts/12_selectable_global_tryouts.rb
|
59
57
|
- tryouts/20_tracks_tryouts.rb
|
60
58
|
- tryouts/30_reporter_tryouts.rb
|
61
59
|
- tryouts/30_timeline_tryouts.rb
|
@@ -91,7 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
91
89
|
requirements: []
|
92
90
|
|
93
91
|
rubyforge_project: benelux
|
94
|
-
rubygems_version: 1.3.
|
92
|
+
rubygems_version: 1.3.3
|
95
93
|
signing_key:
|
96
94
|
specification_version: 3
|
97
95
|
summary: "Benelux: Little freakin' timers for your Ruby codes"
|
data/lib/benelux/count.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
module Benelux
|
2
|
-
|
3
|
-
class Count
|
4
|
-
include Selectable::Object
|
5
|
-
attr_accessor :name
|
6
|
-
def initialize(name, count)
|
7
|
-
@name, @count = name, count
|
8
|
-
end
|
9
|
-
def track
|
10
|
-
@tags[:track]
|
11
|
-
end
|
12
|
-
def inspect
|
13
|
-
"#<%s:%s count=%d name=%s %s>" % [self.class, hexoid, self.to_i, name, tags]
|
14
|
-
end
|
15
|
-
def to_i
|
16
|
-
@count.to_i
|
17
|
-
end
|
18
|
-
def to_s
|
19
|
-
@count.to_s
|
20
|
-
end
|
21
|
-
def ==(other)
|
22
|
-
self.class == other.class &&
|
23
|
-
self.name == other.name &&
|
24
|
-
self.tags == other.tags &&
|
25
|
-
@count.to_i == other.to_i
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
29
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# group "Benelux"
|
3
|
-
#
|
4
|
-
# library :benelux, 'lib'
|
5
|
-
# tryouts "Selectable::Global" do
|
6
|
-
# set :bast, Benelux::Counts.new
|
7
|
-
# setup do
|
8
|
-
#
|
9
|
-
# end
|
10
|
-
#
|
11
|
-
# dream :class, Benelux::Counts
|
12
|
-
# dream :names, [:group1, :group2]
|
13
|
-
# drill "Add groups" do
|
14
|
-
# bast.add_group :group1, :group2
|
15
|
-
# bast
|
16
|
-
# end
|
17
|
-
#
|
18
|
-
# drill "Add objects to groups", true do
|
19
|
-
# bast.send(:group1).class
|
20
|
-
# bast.class.group_class
|
21
|
-
# end
|
22
|
-
#
|
23
|
-
# end
|