tantot 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tantot/collector.rb +3 -2
- data/lib/tantot/collector/block.rb +1 -1
- data/lib/tantot/collector/watcher.rb +1 -1
- data/lib/tantot/extensions/chewy.rb +1 -1
- data/lib/tantot/version.rb +1 -1
- data/performance/profile.rb +83 -0
- data/tantot.gemspec +1 -0
- metadata +16 -2
- data/lib/tantot/collector/base.rb +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a1aca7d8b60134dc22beb994d5d51caabd6b98f9
|
4
|
+
data.tar.gz: c561b19426b24a5650ff23b092274f0212b0e1ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 382ba5b261e10b733db81f5d24c1900292666d70de3aa17cacbc6238dff566a68d7fd9caf4238f2d4609e0cfed015ac1c20f11c8e5f34af0cc73eb4ff991981e
|
7
|
+
data.tar.gz: 1c2799e8e61ae8acecf7c53c38cefbf2b1104bb12e62f7dc6e7884537f732ca3bb5a83255902419ca31103a5a1193db695f5034f2111b04adf861c9c752f2d20
|
data/lib/tantot/collector.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
-
require 'tantot/collector/base'
|
2
1
|
require 'tantot/collector/watcher'
|
3
2
|
require 'tantot/collector/block'
|
4
3
|
|
4
|
+
COLLECTOR_CLASSES = [Tantot::Collector::Block, Tantot::Collector::Watcher]
|
5
|
+
|
5
6
|
module Tantot
|
6
7
|
module Collector
|
7
8
|
class Manager
|
@@ -62,7 +63,7 @@ module Tantot
|
|
62
63
|
end
|
63
64
|
|
64
65
|
def resolve(context)
|
65
|
-
collector_class =
|
66
|
+
collector_class = COLLECTOR_CLASSES.find {|c| c.manages?(context)}
|
66
67
|
return nil unless collector_class
|
67
68
|
@collectors[collector_class] || @collectors[collector_class] = collector_class.new
|
68
69
|
end
|
@@ -72,7 +72,7 @@ module Tantot
|
|
72
72
|
if backreference.any?
|
73
73
|
# Call update_index, will follow normal chewy strategy
|
74
74
|
::Chewy.strategy Tantot.config.chewy_strategy do
|
75
|
-
Tantot.logger.debug "[Tantot] [Chewy] [update_index] #{reference} (#{backreference.count} objects): #{backreference.inspect}"
|
75
|
+
Tantot.logger.debug { "[Tantot] [Chewy] [update_index] #{reference} (#{backreference.count} objects): #{backreference.inspect}" }
|
76
76
|
::Chewy.derive_type(reference).update_index(backreference, options)
|
77
77
|
end
|
78
78
|
end
|
data/lib/tantot/version.rb
CHANGED
@@ -0,0 +1,83 @@
|
|
1
|
+
#/bin/ruby
|
2
|
+
require 'bundler'
|
3
|
+
|
4
|
+
Bundler.require
|
5
|
+
|
6
|
+
require 'benchmark'
|
7
|
+
require 'stackprof'
|
8
|
+
require 'active_record'
|
9
|
+
|
10
|
+
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
|
11
|
+
|
12
|
+
Tantot.logger = Logger.new(nil)
|
13
|
+
Tantot.logger.level = Logger::ERROR
|
14
|
+
|
15
|
+
RUNS = 1000
|
16
|
+
|
17
|
+
def profile(obj)
|
18
|
+
puts obj.class.name
|
19
|
+
obj.setup
|
20
|
+
data = StackProf.run(mode: :cpu) do
|
21
|
+
obj.run
|
22
|
+
end
|
23
|
+
StackProf::Report.new(data).print_text(false, 20)
|
24
|
+
end
|
25
|
+
|
26
|
+
class ProfileRun
|
27
|
+
end
|
28
|
+
|
29
|
+
class BlockRun < ProfileRun
|
30
|
+
class BlockRunCity < ActiveRecord::Base
|
31
|
+
watch(:name) {|changes| }
|
32
|
+
end
|
33
|
+
|
34
|
+
def setup
|
35
|
+
ActiveRecord::Schema.define do
|
36
|
+
create_table :block_run_cities do |t|
|
37
|
+
t.column :name, :string
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def run
|
43
|
+
RUNS.times do
|
44
|
+
city = BlockRunCity.create! name: 'foo'
|
45
|
+
city.name = 'bar'
|
46
|
+
city.save
|
47
|
+
city.destroy
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
class WatcherRun < ProfileRun
|
53
|
+
class WatcherRunWatcher
|
54
|
+
include Tantot::Watcher
|
55
|
+
|
56
|
+
def perform(changes)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
class WatcherRunCity < ActiveRecord::Base
|
61
|
+
watch('watcher_run/watcher_run', :name)
|
62
|
+
end
|
63
|
+
|
64
|
+
def setup
|
65
|
+
ActiveRecord::Schema.define do
|
66
|
+
create_table :watcher_run_cities do |t|
|
67
|
+
t.column :name, :string
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def run
|
73
|
+
RUNS.times do
|
74
|
+
city = WatcherRunCity.create! name: 'foo'
|
75
|
+
city.name = 'bar'
|
76
|
+
city.save
|
77
|
+
city.destroy
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
ProfileRun.descendants.each {|runner| profile(runner.new)}
|
data/tantot.gemspec
CHANGED
@@ -24,6 +24,7 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_development_dependency "rspec", "~> 3.0"
|
25
25
|
spec.add_development_dependency 'sqlite3'
|
26
26
|
spec.add_development_dependency 'database_cleaner'
|
27
|
+
spec.add_development_dependency 'stackprof'
|
27
28
|
|
28
29
|
spec.add_dependency 'activesupport', '>= 3.2'
|
29
30
|
spec.add_dependency 'activerecord', '>= 3.2'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tantot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- François-Pierre Bouchard
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: stackprof
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: activesupport
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -145,7 +159,6 @@ files:
|
|
145
159
|
- lib/tantot.rb
|
146
160
|
- lib/tantot/changes.rb
|
147
161
|
- lib/tantot/collector.rb
|
148
|
-
- lib/tantot/collector/base.rb
|
149
162
|
- lib/tantot/collector/block.rb
|
150
163
|
- lib/tantot/collector/watcher.rb
|
151
164
|
- lib/tantot/config.rb
|
@@ -164,6 +177,7 @@ files:
|
|
164
177
|
- lib/tantot/registry.rb
|
165
178
|
- lib/tantot/version.rb
|
166
179
|
- lib/tantot/watcher.rb
|
180
|
+
- performance/profile.rb
|
167
181
|
- spec/changes_spec.rb
|
168
182
|
- spec/extensions/chewy_spec.rb
|
169
183
|
- spec/sidekiq_spec.rb
|