Sha256: 4bf89b554fbcaa8c622fb8d32de00e28fda0909b2118599b90ccc17a16efc488
Contents?: true
Size: 1.3 KB
Versions: 1
Compression:
Stored size: 1.3 KB
Contents
== Summary When testing products such as services which need to be stress tested as much as possible, it's necessary to use multi-threading to get as close to real world usage as possible. To reduce the duplication of code, this plugin utilizes Ruby's built-in Benchmark for the base functionality while preventing the output from clobbering through the use of thread-specific IO buffers. == Install Download the gem or source from http://rubyforge.org/projects/revhealth/ == Dependencies None save for Ruby 1.8.x. == Usage Anywhere you need to do multi-threaded testing, just use 'threadsafe_bm' instead of the standard 'bm' call. The method has also been aliased as 'ts_bm'. == Sample require 'rubygems' require_gem 'threadsafe_benchmark' include ThreadsafeBenchmark threads = [] max_num = 5000 5.to_i.times { |i| threads << Thread.new(max_num) { |n| threadsafe_bm(6) { |x| x.report("for:") { for i in 1..n; a = "1"; end } x.report("times:") { n.times do ; a = "1"; end } x.report("upto:") { 1.upto(n) do ; a = "1"; end } } } } threads.each { |t| t.join } == License This code is released under the MIT license. == Support The RubyForge page for all RHG-related plugins is http://rubyforge.org/projects/revhealth You can email the RHG Rails team at rails-trunk@revolutionhealth.com
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
threadsafe_benchmark-1.0.0 | README |