ruby_event_store-profiler 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +6 -10
- data/lib/ruby_event_store/profiler/version.rb +4 -2
- data/lib/ruby_event_store/profiler.rb +11 -20
- metadata +7 -10
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3121a6f9d365e7d3b18cd8e351a87952740abd9efd98b07f463bf215f5897df2
|
|
4
|
+
data.tar.gz: d254f2208308a5b6ee99a1ab01845dcc2a24400834969ee657ae93dee7189cbb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e3f5fc0a96daee1f9a01c19d1a1aac920e752fb907b351cd9e67bee61b6cca29841dcb00bf95f9df1ad9f8688c440151a69b3f7bb27129c605cb9f423218a825
|
|
7
|
+
data.tar.gz: 2c27b6e83060ef45ff988235db77bb25797de0cc06dfe9fbf009b52f0f958dd37eb1fbde00bf135ae0b7214d081aaa54dcb04809240196dca4cde5305f49cffe
|
data/README.md
CHANGED
|
@@ -2,21 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
Simplistic profiler hooking into RubyEventStore instrumenation infrastructure.
|
|
4
4
|
|
|
5
|
-
|
|
6
5
|
```ruby
|
|
7
6
|
DummyEvent = Class.new(RubyEventStore::Event)
|
|
8
7
|
|
|
9
|
-
instrumenter =
|
|
10
|
-
|
|
11
|
-
event_store =
|
|
8
|
+
instrumenter = ActiveSupport::Notifications
|
|
9
|
+
event_store =
|
|
12
10
|
RubyEventStore::Client.new(
|
|
13
11
|
repository: RubyEventStore::InstrumentedRepository.new(RubyEventStore::InMemoryRepository.new, instrumenter),
|
|
14
12
|
mapper: RubyEventStore::Mappers::InstrumentedMapper.new(RubyEventStore::Mappers::Default.new, instrumenter),
|
|
15
|
-
dispatcher: RubyEventStore::InstrumentedDispatcher.new(RubyEventStore::
|
|
13
|
+
dispatcher: RubyEventStore::InstrumentedDispatcher.new(RubyEventStore::SyncScheduler.new, instrumenter),
|
|
16
14
|
)
|
|
17
15
|
|
|
18
|
-
repository =
|
|
19
|
-
AggregateRoot::InstrumentedRepository.new(AggregateRoot::Repository.new(event_store), instrumenter)
|
|
16
|
+
repository = AggregateRoot::InstrumentedRepository.new(AggregateRoot::Repository.new(event_store), instrumenter)
|
|
20
17
|
|
|
21
18
|
class Bazinga
|
|
22
19
|
include AggregateRoot
|
|
@@ -29,11 +26,10 @@ class Bazinga
|
|
|
29
26
|
end
|
|
30
27
|
end
|
|
31
28
|
|
|
32
|
-
profiler =
|
|
33
|
-
RubyEventStore::Profiler.new(instrumenter)
|
|
29
|
+
profiler = RubyEventStore::Profiler.new(instrumenter)
|
|
34
30
|
profiler.measure do
|
|
35
31
|
aggregate = repository.load(Bazinga.new, "bazinga")
|
|
36
32
|
aggregate.do_the_dummy
|
|
37
33
|
repository.store(aggregate, "bazinga")
|
|
38
34
|
end
|
|
39
|
-
```
|
|
35
|
+
```
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module RubyEventStore
|
|
2
4
|
class Profiler
|
|
3
|
-
METRICS = [
|
|
4
|
-
/rails_event_store/,
|
|
5
|
-
/aggregate_root/,
|
|
6
|
-
"total"
|
|
7
|
-
].freeze
|
|
5
|
+
METRICS = [/ruby_event_store/, /aggregate_root/, "total"].freeze
|
|
8
6
|
private_constant :METRICS
|
|
9
7
|
|
|
10
8
|
def initialize(instrumenter)
|
|
@@ -12,33 +10,26 @@ module RubyEventStore
|
|
|
12
10
|
end
|
|
13
11
|
|
|
14
12
|
def measure(&block)
|
|
15
|
-
output =
|
|
16
|
-
Hash.new { 0 }
|
|
13
|
+
output = Hash.new(0)
|
|
17
14
|
subscribers =
|
|
18
15
|
METRICS.map do |name|
|
|
19
16
|
@instrumenter.subscribe(name) do |name, start, finish|
|
|
20
|
-
metric_name = name.split(
|
|
21
|
-
duration
|
|
17
|
+
metric_name = name.split(".").first
|
|
18
|
+
duration = 1000.0 * (finish - start)
|
|
22
19
|
output[metric_name] += duration
|
|
23
20
|
end
|
|
24
21
|
end
|
|
25
22
|
|
|
26
|
-
@instrumenter.instrument(
|
|
27
|
-
block.call
|
|
28
|
-
end
|
|
23
|
+
@instrumenter.instrument("total") { block.call }
|
|
29
24
|
|
|
30
|
-
subscribers.each
|
|
31
|
-
@instrumenter.unsubscribe(name)
|
|
32
|
-
end
|
|
25
|
+
subscribers.each { |s| @instrumenter.unsubscribe(s) }
|
|
33
26
|
|
|
34
|
-
total = output.delete(
|
|
27
|
+
total = output.delete("total")
|
|
35
28
|
|
|
36
29
|
puts "%s %s %s" % ["metric".ljust(18), "ms".rjust(7), "%".rjust(6)]
|
|
37
30
|
puts "\u2500" * 33
|
|
38
31
|
|
|
39
|
-
output.each
|
|
40
|
-
puts "%s %7.2f %6.2f" % [metric.ljust(18), duration, (duration/total * 100)]
|
|
41
|
-
end
|
|
32
|
+
output.each { |metric, duration| puts "%s %7.2f %6.2f" % [metric.ljust(18), duration, (duration / total * 100)] }
|
|
42
33
|
|
|
43
34
|
puts
|
|
44
35
|
puts "%s %7.2f %6.2f" % ["total".ljust(18), total, 100]
|
|
@@ -46,4 +37,4 @@ module RubyEventStore
|
|
|
46
37
|
output.merge("total" => total)
|
|
47
38
|
end
|
|
48
39
|
end
|
|
49
|
-
end
|
|
40
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ruby_event_store-profiler
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Arkency
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: ruby_event_store
|
|
@@ -19,7 +18,7 @@ dependencies:
|
|
|
19
18
|
version: 1.0.0
|
|
20
19
|
- - "<"
|
|
21
20
|
- !ruby/object:Gem::Version
|
|
22
|
-
version:
|
|
21
|
+
version: 4.0.0
|
|
23
22
|
type: :runtime
|
|
24
23
|
prerelease: false
|
|
25
24
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -29,8 +28,7 @@ dependencies:
|
|
|
29
28
|
version: 1.0.0
|
|
30
29
|
- - "<"
|
|
31
30
|
- !ruby/object:Gem::Version
|
|
32
|
-
version:
|
|
33
|
-
description:
|
|
31
|
+
version: 4.0.0
|
|
34
32
|
email: dev@arkency.com
|
|
35
33
|
executables: []
|
|
36
34
|
extensions: []
|
|
@@ -47,7 +45,7 @@ metadata:
|
|
|
47
45
|
homepage_uri: https://railseventstore.org
|
|
48
46
|
source_code_uri: https://github.com/RailsEventStore/rails_event_store
|
|
49
47
|
bug_tracker_uri: https://github.com/RailsEventStore/rails_event_store/issues
|
|
50
|
-
|
|
48
|
+
rubygems_mfa_required: 'true'
|
|
51
49
|
rdoc_options: []
|
|
52
50
|
require_paths:
|
|
53
51
|
- lib
|
|
@@ -55,15 +53,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
55
53
|
requirements:
|
|
56
54
|
- - ">="
|
|
57
55
|
- !ruby/object:Gem::Version
|
|
58
|
-
version: '2.
|
|
56
|
+
version: '2.7'
|
|
59
57
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
60
58
|
requirements:
|
|
61
59
|
- - ">="
|
|
62
60
|
- !ruby/object:Gem::Version
|
|
63
61
|
version: '0'
|
|
64
62
|
requirements: []
|
|
65
|
-
rubygems_version: 3.1
|
|
66
|
-
signing_key:
|
|
63
|
+
rubygems_version: 3.7.1
|
|
67
64
|
specification_version: 4
|
|
68
65
|
summary: Dead-simple profiling based on instrumentation built into RubyEventStore
|
|
69
66
|
test_files: []
|