Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Release 0.5.2 (messages)

  • Loading branch information...
commit 4e178023b9df1a3d54a5aaf9262f5111c0b8f522 1 parent c8b0c2a
@delano authored
View
8 CHANGES.txt
@@ -1,12 +1,16 @@
BENELUX, CHANGES
+#### 0.5.2 (2009-11-02) ###############################
+
+* ADDED: Selectable#rfilter
+* ADDED: Timeline#messages
+
+
#### 0.5.1 (2009-10-29) ###############################
* FIXED: Timeline#clear
* ADDED: Thread#rotate_timeline
* ADDED: Stats#clear
-* ADDED: Selectable#rfilter
-* ADDED: Timeline#messages
#### 0.5.0 (2009-10-21) ###############################
View
8 README.rdoc
@@ -1,12 +1,14 @@
-= Benelux v0.4 (IN PROGRESS)
+= Benelux v0.5
-<b>A madhouse of timers for your Ruby codes</b>
+<b>A mad timeline for your Ruby codes</b>
== Features
* Create timers for any Ruby method
+* Store arbitrary messages
* Granular statistics
+* Thread-safe
== Installation
@@ -32,7 +34,7 @@ Get it in one of the following ways:
== Thanks
* Alexis Sellier for fielding my Ruby questions
-* Tara Dougans for the motivational speaches
+* Tara Dougans for the motivational speeches
== License
View
5 benelux.gemspec
@@ -1,8 +1,8 @@
@spec = Gem::Specification.new do |s|
s.name = "benelux"
s.rubyforge_project = 'benelux'
- s.version = "0.5.1"
- s.summary = "Benelux: Little freakin' timers for your Ruby codes"
+ s.version = "0.5.2"
+ s.summary = "Benelux: A mad timeline for Ruby codes"
s.description = s.summary
s.author = "Delano Mandelbaum"
s.email = "delano@solutious.com"
@@ -29,7 +29,6 @@
lib/benelux/mixins/thread.rb
lib/benelux/packer.rb
lib/benelux/range.rb
- lib/benelux/reporter.rb
lib/benelux/stats.rb
lib/benelux/timeline.rb
lib/benelux/track.rb
View
2  lib/benelux.rb
@@ -5,7 +5,7 @@
require 'selectable'
module Benelux
- VERSION = "0.5.1"
+ VERSION = "0.5.2"
NOTSUPPORTED = [Class, Object, Kernel]
class BeneluxError < RuntimeError; end
View
93 lib/benelux/reporter.rb
@@ -1,93 +0,0 @@
-
-module Benelux
- class Reporter
- attr_reader :thread
- attr_reader :thwait
- @@mutex = Mutex.new
- def initialize(*threads)
- @thwait = ThreadsWait.new
- @abort, @running = false, false
- @tmerge = Benelux::Stats::Calculator.new
- add_threads *threads
- @tbd = []
- @thread = create_reporting_thread
- end
- def create_reporting_thread(priority=-3)
- t = Thread.new do
- 5.times { # Give the app 1 second to generate threads
- break if @start && !@thwait.empty?
- sleep 0.2
- }
-
- run_loop
- end
- t.priority = priority
- t
- end
- def add_threads(*threads)
- threads.each do |thread|
- raise BadRecursion, "Cannot report on self" if thread == @thread
- next if thread == Thread.main
- @thwait.join_nowait thread
- end
- @start = true
- end
- alias_method :add_thread, :add_threads
- def running_threads?
- # Any status that is not nil or false is running
- !@thwait.threads.select { |t| !t.nil? && t.status }.empty?
- end
-
- def run_loop
- loop do
- break if @abort
- process(@tbd)
- if @thwait.empty?
- sleep 0.01 # prevent mad thrashing.
- # If there are no threads running we can stop
- # because there are none waiting in the queue.
- running_threads? ? next : break
- end
- t = @thwait.next_wait
- @tbd << t.timeline
- end
- end
- def process(tbd)
- return if tbd.empty?
- (start = Time.now)
- Benelux.timeline.merge! *tbd
- (endt = Time.now)
- dur = (endt - start).to_f
- #p [:processed, tbd.size, dur]
- tbd.clear
- @tmerge.sample dur
- end
- # We don't add the main thread to the wait group
- # so we need to manually force processing for
- # that thread.
- def force_update
- @abort = false
- @tbd << Thread.current.timeline
- run_loop
- end
- # Call this once the active threads have stopped. It
- # increases the priority of the processing thread,
- # waits for it to finish and then calls force_update
- # to get the main threads stats into the timeline.
- def wait
- if @thread && Thread.current == Thread.main
- @abort = true
- @thread.priority = 0
- @thread.join if @thread.status
- force_update
- else
- msg = "Not main thread. Skipping call to wait from #{caller[0]}"
- Benelux.ld msg
- end
- end
- def stop() @abort = true end
- def done?() @done end
- def aborted?() @abort end
- def running?() @running end
- end
-end
Please sign in to comment.
Something went wrong with that request. Please try again.