mongoo 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -17,4 +17,6 @@ group :development do
17
17
  gem "bundler", "~> 1.0.0"
18
18
  gem "jeweler", "~> 1.5.1"
19
19
  gem "rcov", ">= 0"
20
+ gem "perftools.rb", :require => "perftools"
21
+ gem "bson_ext", "~> 1.3.1"
20
22
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.3.1
@@ -187,23 +187,7 @@ module Mongoo
187
187
  end
188
188
 
189
189
  def verify_attributes_in_mongohash(hash)
190
- known_keys = self.class.attributes.keys
191
- known_keys << "_id"
192
- hash.dot_list.each do |k|
193
- unless known_keys.include?(k)
194
- k.split(".").each do |part|
195
- if opts = self.class.attributes[part]
196
- if opts[:type] == :hash
197
- known_keys << k
198
- end
199
- end
200
- end
201
- unless known_keys.include?(k)
202
- # this is just annoying.
203
- #raise Mongoo::UnknownAttributeError, k.to_s
204
- end
205
- end
206
- end
190
+ true
207
191
  end # verify_attributes_in_mongohash
208
192
  end
209
193
  end
@@ -1,18 +1,22 @@
1
1
  module Mongoo
2
2
  module HashExt
3
3
  def deep_stringify_keys
4
- Marshal.load(Marshal.dump(self)).deep_stringify_keys!
4
+ deep_clone.deep_stringify_keys!
5
5
  end
6
6
 
7
7
  def deep_stringify_keys!
8
8
  keys.each do |key|
9
9
  self[key.to_s] = delete(key)
10
10
  if self[key.to_s].is_a?(Hash)
11
- self[key.to_s].stringify_keys!
11
+ self[key.to_s].deep_stringify_keys!
12
12
  end
13
13
  end
14
14
  self
15
15
  end
16
+
17
+ def deep_clone
18
+ Marshal.load(Marshal.dump(self))
19
+ end
16
20
  end
17
21
  end
18
22
 
@@ -16,7 +16,7 @@ module Mongoo
16
16
  end
17
17
 
18
18
  def deep_clone
19
- Mongoo::Mongohash.new(Marshal.load(Marshal.dump self.raw_hash))
19
+ Mongoo::Mongohash.new(self.raw_hash.deep_clone)
20
20
  end
21
21
 
22
22
  def dot_set(k,v)
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{mongoo}
8
- s.version = "0.3.0"
8
+ s.version = "0.3.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ben Myles"]
12
- s.date = %q{2011-05-13}
12
+ s.date = %q{2011-05-17}
13
13
  s.description = %q{Simple object mapper for MongoDB}
14
14
  s.email = %q{ben.myles@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -43,12 +43,13 @@ Gem::Specification.new do |s|
43
43
  "test/test_async.rb",
44
44
  "test/test_identity_map.rb",
45
45
  "test/test_mongohash.rb",
46
- "test/test_mongoo.rb"
46
+ "test/test_mongoo.rb",
47
+ "test/test_performance.rb"
47
48
  ]
48
49
  s.homepage = %q{http://github.com/benmyles/mongoo}
49
50
  s.licenses = ["MIT"]
50
51
  s.require_paths = ["lib"]
51
- s.rubygems_version = %q{1.6.1}
52
+ s.rubygems_version = %q{1.6.2}
52
53
  s.summary = %q{Object mapper for MongoDB}
53
54
  s.test_files = [
54
55
  "test/helper.rb",
@@ -56,7 +57,8 @@ Gem::Specification.new do |s|
56
57
  "test/test_async.rb",
57
58
  "test/test_identity_map.rb",
58
59
  "test/test_mongohash.rb",
59
- "test/test_mongoo.rb"
60
+ "test/test_mongoo.rb",
61
+ "test/test_performance.rb"
60
62
  ]
61
63
 
62
64
  if s.respond_to? :specification_version then
@@ -73,6 +75,8 @@ Gem::Specification.new do |s|
73
75
  s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
74
76
  s.add_development_dependency(%q<jeweler>, ["~> 1.5.1"])
75
77
  s.add_development_dependency(%q<rcov>, [">= 0"])
78
+ s.add_development_dependency(%q<perftools.rb>, [">= 0"])
79
+ s.add_development_dependency(%q<bson_ext>, ["~> 1.3.1"])
76
80
  else
77
81
  s.add_dependency(%q<i18n>, [">= 0.4.1"])
78
82
  s.add_dependency(%q<activesupport>, [">= 3.0.3"])
@@ -84,6 +88,8 @@ Gem::Specification.new do |s|
84
88
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
85
89
  s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
86
90
  s.add_dependency(%q<rcov>, [">= 0"])
91
+ s.add_dependency(%q<perftools.rb>, [">= 0"])
92
+ s.add_dependency(%q<bson_ext>, ["~> 1.3.1"])
87
93
  end
88
94
  else
89
95
  s.add_dependency(%q<i18n>, [">= 0.4.1"])
@@ -96,6 +102,8 @@ Gem::Specification.new do |s|
96
102
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
97
103
  s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
98
104
  s.add_dependency(%q<rcov>, [">= 0"])
105
+ s.add_dependency(%q<perftools.rb>, [">= 0"])
106
+ s.add_dependency(%q<bson_ext>, ["~> 1.3.1"])
99
107
  end
100
108
  end
101
109
 
@@ -0,0 +1,42 @@
1
+ require 'helper'
2
+ require 'perftools'
3
+
4
+ class TestPerformance < Test::Unit::TestCase
5
+
6
+ def setup
7
+ [Person, TvShow, SearchIndex].each do |obj|
8
+ obj.drop
9
+ obj.create_indexes
10
+ end
11
+ end
12
+
13
+ should "be able to find 1000 times" do
14
+ p = Person.new
15
+ p.name = "Ben"
16
+ p.visits = 10
17
+ p.interests = ["skydiving","coding","reading","swimming"]
18
+ p.jobs.total = 5
19
+ p.jobs.professional = ["pro","fess","ion","al"]
20
+ p.jobs.volunteer = ["vol","un","teer"]
21
+ p.jobs.internships.high_school = ["one","two","three","four"]
22
+ p.location.city = "San Francisco"
23
+ p.location.demographics.crime_rate = :medium
24
+ p.location.demographics.education_quality = :high
25
+ p.misc = { "a" => "b", "c" => "d", "e" => "f", "g" => "h" }
26
+ 1.upto(200) { |i| p.misc["i#{i}"] = "......... #{i} ........." }
27
+ p.insert!
28
+
29
+ t1 = Time.now.utc.to_f
30
+ PerfTools::CpuProfiler.start("/tmp/mongoo_test_performance") do
31
+ 1000.times do |i|
32
+ Person.find_one(p.id)
33
+ end
34
+ end
35
+ t2 = Time.now.utc.to_f
36
+
37
+ out = `pprof.rb --text /tmp/mongoo_test_performance`
38
+ puts out
39
+
40
+ puts "Perf: #{t2-t1}"
41
+ end
42
+ end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: mongoo
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.3.0
5
+ version: 0.3.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Ben Myles
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-05-13 00:00:00 -07:00
13
+ date: 2011-05-17 00:00:00 -07:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -123,6 +123,28 @@ dependencies:
123
123
  type: :development
124
124
  prerelease: false
125
125
  version_requirements: *id010
126
+ - !ruby/object:Gem::Dependency
127
+ name: perftools.rb
128
+ requirement: &id011 !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ version: "0"
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: *id011
137
+ - !ruby/object:Gem::Dependency
138
+ name: bson_ext
139
+ requirement: &id012 !ruby/object:Gem::Requirement
140
+ none: false
141
+ requirements:
142
+ - - ~>
143
+ - !ruby/object:Gem::Version
144
+ version: 1.3.1
145
+ type: :development
146
+ prerelease: false
147
+ version_requirements: *id012
126
148
  description: Simple object mapper for MongoDB
127
149
  email: ben.myles@gmail.com
128
150
  executables: []
@@ -160,6 +182,7 @@ files:
160
182
  - test/test_identity_map.rb
161
183
  - test/test_mongohash.rb
162
184
  - test/test_mongoo.rb
185
+ - test/test_performance.rb
163
186
  has_rdoc: true
164
187
  homepage: http://github.com/benmyles/mongoo
165
188
  licenses:
@@ -174,7 +197,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
174
197
  requirements:
175
198
  - - ">="
176
199
  - !ruby/object:Gem::Version
177
- hash: -3196476684317221338
200
+ hash: -2907379497624021949
178
201
  segments:
179
202
  - 0
180
203
  version: "0"
@@ -187,7 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
187
210
  requirements: []
188
211
 
189
212
  rubyforge_project:
190
- rubygems_version: 1.6.1
213
+ rubygems_version: 1.6.2
191
214
  signing_key:
192
215
  specification_version: 3
193
216
  summary: Object mapper for MongoDB
@@ -198,3 +221,4 @@ test_files:
198
221
  - test/test_identity_map.rb
199
222
  - test/test_mongohash.rb
200
223
  - test/test_mongoo.rb
224
+ - test/test_performance.rb