effective_test_bot 1.5.3 → 1.5.4
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 00e994d7cc48e7ad3f6594daf5f8e13678fcc85be4b178d8565f3d4666f5724e
|
4
|
+
data.tar.gz: 3b2ec36407c22b8b8639e6a585e2fea987033affdacb0ab61e551f183965b55b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32c6e8f8e86c813d29dcc283a449eda202b61791ad4ae4cdb599a7db95ab4678f9d93f9d248507ec07265f6c1a45a42b62355d42a4549d765b1684f4ad2c52b5
|
7
|
+
data.tar.gz: 6d9ad23ef9fe2bf9dd41b7ef7ec1d9664735a38f0ff8187d65bb09a85aa66c455ac4f9e26c276b0fcbe00697ea04ae796c483628d96189614d1a0f5a16ebde53
|
@@ -10,6 +10,7 @@ module EffectiveTestBot
|
|
10
10
|
include EffectiveTestBotFormHelper
|
11
11
|
include EffectiveTestBotLoginHelper
|
12
12
|
include EffectiveTestBotMinitestHelper
|
13
|
+
include EffectiveTestBotPerformance
|
13
14
|
include EffectiveTestBotScreenshotsHelper
|
14
15
|
include EffectiveTestBotTestHelper
|
15
16
|
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module EffectiveTestBotPerformance
|
2
|
+
def assert_performance(milliseconds: 250, print_results: false, &block)
|
3
|
+
result = performance_test(print_results: print_results, &block)
|
4
|
+
|
5
|
+
assert (result < milliseconds), "Expected performance to be less than #{milliseconds}ms, but it was #{result}ms"
|
6
|
+
end
|
7
|
+
|
8
|
+
def performance_test(warmups: 2, iterations: 10, print_results: true, &block)
|
9
|
+
raise('expected a block') unless block_given?
|
10
|
+
raise('please install the ruby-prof gem') unless defined?(RubyProf)
|
11
|
+
|
12
|
+
# Warmup
|
13
|
+
warmups.times { block.call() }
|
14
|
+
|
15
|
+
# Use ruby-prof to Profile
|
16
|
+
profile = RubyProf::Profile.new(track_allocations: true)
|
17
|
+
|
18
|
+
results = profile.profile do
|
19
|
+
iterations.times do
|
20
|
+
print '.'
|
21
|
+
block.call()
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# Return a single number result
|
26
|
+
milliseconds = ((results.threads.sum { |thread| thread.total_time } * 1000.0) / iterations.to_f).round
|
27
|
+
|
28
|
+
# Print results
|
29
|
+
print_performance_test_results(results, milliseconds) if print_results
|
30
|
+
|
31
|
+
# Returns an integer number of milliseconds
|
32
|
+
milliseconds
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def print_performance_test_results(results, milliseconds)
|
38
|
+
puts('')
|
39
|
+
|
40
|
+
path = Rails.application.root.join('tmp')
|
41
|
+
|
42
|
+
# Profile Graph
|
43
|
+
filename = path.join('profile-graph.html')
|
44
|
+
File.open(filename, 'w+') { |file| RubyProf::GraphHtmlPrinter.new(results).print(file) }
|
45
|
+
puts("Profile Graph: #{filename}")
|
46
|
+
|
47
|
+
# Profile Flat
|
48
|
+
filename = path.join('profile-flat.txt')
|
49
|
+
File.open(filename, 'w+') { |file| RubyProf::FlatPrinter.new(results).print(file) }
|
50
|
+
puts("Profile Flat: #{filename}")
|
51
|
+
|
52
|
+
# Profile Stack
|
53
|
+
filename = path.join('profile-stack.html')
|
54
|
+
File.open(filename, 'w+') { |file| RubyProf::CallStackPrinter.new(results).print(file) }
|
55
|
+
puts("Profile Stack: #{filename}")
|
56
|
+
|
57
|
+
# Total Performance
|
58
|
+
puts "Performance: #{milliseconds}ms"
|
59
|
+
|
60
|
+
puts('')
|
61
|
+
end
|
62
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_test_bot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-12-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -161,6 +161,7 @@ files:
|
|
161
161
|
- test/support/effective_test_bot_login_helper.rb
|
162
162
|
- test/support/effective_test_bot_minitest_helper.rb
|
163
163
|
- test/support/effective_test_bot_mocks.rb
|
164
|
+
- test/support/effective_test_bot_performance.rb
|
164
165
|
- test/support/effective_test_bot_screenshots_helper.rb
|
165
166
|
- test/support/effective_test_bot_test_helper.rb
|
166
167
|
- test/test_bot/system/application_test.rb
|