refuse 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/README.textile +33 -0
- data/Rakefile +2 -0
- data/lib/refuse/version.rb +3 -0
- data/lib/refuse.rb +17 -0
- data/refuse.gemspec +21 -0
- metadata +74 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.textile
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
h1. Defer garbage collection to speed up your tests.
|
2
|
+
|
3
|
+
Spurned on by a burgeoning test suite, and inspired by "Crank Your Specs":http://blog.carbonfive.com/2011/02/02/crank-your-specs/ and "The road to faster tests":http://37signals.com/svn/posts/2742-the-road-to-faster-tests, I've wrapped up the garbage collection hack to make it easy to reuse.
|
4
|
+
|
5
|
+
h2. Usage
|
6
|
+
|
7
|
+
h3. Rspec
|
8
|
+
|
9
|
+
In your @spec_helper.rb@:
|
10
|
+
|
11
|
+
<pre>config.before(:each) do
|
12
|
+
Refuse.disable
|
13
|
+
end
|
14
|
+
|
15
|
+
config.after(:each) do
|
16
|
+
Refuse.collect
|
17
|
+
end</pre>
|
18
|
+
|
19
|
+
h3. Cucumber
|
20
|
+
|
21
|
+
In @env.rb@:
|
22
|
+
|
23
|
+
<pre>Before do
|
24
|
+
Refuse.disable
|
25
|
+
end
|
26
|
+
|
27
|
+
After do
|
28
|
+
Refuse.collect
|
29
|
+
end</pre>
|
30
|
+
|
31
|
+
h3. Test::Unit
|
32
|
+
|
33
|
+
Coming soon!
|
data/Rakefile
ADDED
data/lib/refuse.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
module Refuse
|
2
|
+
DEFERRED_GC_THRESHOLD = (ENV['DEFER_GC'] || 1.0).to_f
|
3
|
+
@@last_gc_run = Time.now
|
4
|
+
|
5
|
+
def self.disable
|
6
|
+
GC.disable if DEFERRED_GC_THRESHOLD > 0
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.collect
|
10
|
+
if DEFERRED_GC_THRESHOLD > 0 && Time.now - @@last_gc_run >= DEFERRED_GC_THRESHOLD
|
11
|
+
GC.enable
|
12
|
+
GC.start
|
13
|
+
GC.disable
|
14
|
+
@@last_gc_run = Time.now
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/refuse.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "refuse/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "refuse"
|
7
|
+
s.version = Refuse::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Brian Ryckbost"]
|
10
|
+
s.email = ["brian@collectiveidea.com"]
|
11
|
+
s.homepage = "http://ryckbost.com"
|
12
|
+
s.summary = %q{Defer garbage collection}
|
13
|
+
s.description = %q{Wrap up some common functionality of deferring garbage collection. Often used to speed up test suites by 40%-60%.}
|
14
|
+
|
15
|
+
s.rubyforge_project = "refuse"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: refuse
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Brian Ryckbost
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-05-26 00:00:00 -04:00
|
19
|
+
default_executable:
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description: Wrap up some common functionality of deferring garbage collection. Often used to speed up test suites by 40%-60%.
|
23
|
+
email:
|
24
|
+
- brian@collectiveidea.com
|
25
|
+
executables: []
|
26
|
+
|
27
|
+
extensions: []
|
28
|
+
|
29
|
+
extra_rdoc_files: []
|
30
|
+
|
31
|
+
files:
|
32
|
+
- .gitignore
|
33
|
+
- Gemfile
|
34
|
+
- README.textile
|
35
|
+
- Rakefile
|
36
|
+
- lib/refuse.rb
|
37
|
+
- lib/refuse/version.rb
|
38
|
+
- refuse.gemspec
|
39
|
+
has_rdoc: true
|
40
|
+
homepage: http://ryckbost.com
|
41
|
+
licenses: []
|
42
|
+
|
43
|
+
post_install_message:
|
44
|
+
rdoc_options: []
|
45
|
+
|
46
|
+
require_paths:
|
47
|
+
- lib
|
48
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
hash: 3
|
54
|
+
segments:
|
55
|
+
- 0
|
56
|
+
version: "0"
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
hash: 3
|
63
|
+
segments:
|
64
|
+
- 0
|
65
|
+
version: "0"
|
66
|
+
requirements: []
|
67
|
+
|
68
|
+
rubyforge_project: refuse
|
69
|
+
rubygems_version: 1.4.2
|
70
|
+
signing_key:
|
71
|
+
specification_version: 3
|
72
|
+
summary: Defer garbage collection
|
73
|
+
test_files: []
|
74
|
+
|