execution_time 0.1.3 → 0.1.5
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 +18 -1
- data/lib/execution_time/railtie.rb +0 -2
- data/lib/execution_time/version.rb +1 -1
- data/lib/execution_time.rb +4 -4
- metadata +31 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a5175d8322ecf49b9bd3fa736b299e5d3e1c1d40bd96f117cd150ad1838d41d6
|
4
|
+
data.tar.gz: 1cdfe9c93d970757d30a31776f190022c873c826d997f0266b17b5ec8519f837
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10113e9c6a2f847846a72655083afa326db2e90e7b15a117ed333270bf8f56255a5703423836887fd04a248274b2d0e604c9b7f0f4ef6308cf76a9c493d5db09
|
7
|
+
data.tar.gz: f6c2a269e430a2717ff20ff1773bd173102ea0fd692e80bd14ff608a40f84597c45c1b4ed4bb749025f7ec34e481b74ada9ed90dc7546b0a9994d75200b907fe
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# ExecutionTime
|
2
2
|
|
3
|
+
[](https://buymeacoffee.com/igorkasyanchuk)
|
4
|
+
|
3
5
|
Monitor execution time and other metrics directly in `rails console`, similar to what you see after each request.
|
4
6
|
|
5
7
|
`[METRICS] Completed in 908.3ms | Allocations: 2894 | ActiveRecord: 0.9ms (queries: 13)`
|
@@ -17,7 +19,7 @@ If you want to measure few lines of code just wrap it with `begin/end`:
|
|
17
19
|
[4] pry(main)* User.first.first_name.size
|
18
20
|
[4] pry(main)* a = User.count + 1
|
19
21
|
[4] pry(main)* b = User.second.last_name.size
|
20
|
-
[4] pry(main)* end
|
22
|
+
[4] pry(main)* end
|
21
23
|
User Load (0.4ms) SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT $1 [["LIMIT", 1]]
|
22
24
|
(3.6ms) SELECT COUNT(*) FROM "users"
|
23
25
|
User Load (0.3ms) SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT $1 OFFSET $2 [["LIMIT", 1], ["OFFSET", 1]]
|
@@ -33,6 +35,15 @@ Add this line to your application's Gemfile:
|
|
33
35
|
gem 'execution_time'
|
34
36
|
```
|
35
37
|
|
38
|
+
or
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
gem "irb"
|
42
|
+
gem "execution_time"
|
43
|
+
|
44
|
+
# sometimes IRB is loaded after execution_time gem, so we need to load it first
|
45
|
+
```
|
46
|
+
|
36
47
|
## First run
|
37
48
|
|
38
49
|
Sometime you can see that there are more SQL queries or allocated objects because Ruby is just loading objects in memory or verifying connection to the DB.
|
@@ -51,6 +62,12 @@ You are welcome to contribute.
|
|
51
62
|
## Contributos
|
52
63
|
|
53
64
|
- https://github.com/nbulaj
|
65
|
+
- https://github.com/ruban-thilak
|
54
66
|
|
55
67
|
## License
|
56
68
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
69
|
+
|
70
|
+
[<img src="https://github.com/igorkasyanchuk/rails_time_travel/blob/main/docs/more_gems.png?raw=true"
|
71
|
+
/>](https://www.railsjazz.com/?utm_source=github&utm_medium=bottom&utm_campaign=execution_time)
|
72
|
+
|
73
|
+
[](https://buymeacoffee.com/igorkasyanchuk)
|
@@ -1,6 +1,5 @@
|
|
1
1
|
module ExecutionTime
|
2
2
|
class Railtie < ::Rails::Railtie
|
3
|
-
|
4
3
|
console do
|
5
4
|
if const_defined?("Pry")
|
6
5
|
Pry.send :prepend, ExecutionTime::PryExt
|
@@ -9,6 +8,5 @@ module ExecutionTime
|
|
9
8
|
IRB::Context.send :prepend, ExecutionTime::IrbContextExt
|
10
9
|
end
|
11
10
|
end
|
12
|
-
|
13
11
|
end
|
14
12
|
end
|
data/lib/execution_time.rb
CHANGED
@@ -49,13 +49,13 @@ module ExecutionTime
|
|
49
49
|
|
50
50
|
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
51
51
|
before = GC.stat(:total_allocated_objects)
|
52
|
-
ActiveRecord::
|
52
|
+
ActiveRecord::RuntimeRegistry.reset
|
53
53
|
|
54
54
|
result = yield
|
55
55
|
|
56
56
|
after = GC.stat(:total_allocated_objects)
|
57
57
|
duration = (Process.clock_gettime(Process::CLOCK_MONOTONIC) - start)
|
58
|
-
db_after = ActiveRecord::
|
58
|
+
db_after = ActiveRecord::RuntimeRegistry.reset
|
59
59
|
|
60
60
|
info = "Completed in #{(duration * 1000).round(1)}ms | Allocations: #{after - before}"
|
61
61
|
|
@@ -72,7 +72,7 @@ module ExecutionTime
|
|
72
72
|
module IrbContextExt
|
73
73
|
def evaluate(*args)
|
74
74
|
Measurer.watch do
|
75
|
-
if RUBY_VERSION.to_s =~ /^3/
|
75
|
+
if RUBY_VERSION.to_s =~ /^3/ && !args[2].nil?
|
76
76
|
super(args[0], args[1], **args[2])
|
77
77
|
else
|
78
78
|
super(*args)
|
@@ -99,4 +99,4 @@ module ExecutionTime
|
|
99
99
|
super(code)
|
100
100
|
end
|
101
101
|
end
|
102
|
-
end
|
102
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: execution_time
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Kasyanchuk
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-05-28 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: rails
|
@@ -38,6 +37,34 @@ dependencies:
|
|
38
37
|
- - ">="
|
39
38
|
- !ruby/object:Gem::Version
|
40
39
|
version: '0'
|
40
|
+
- !ruby/object:Gem::Dependency
|
41
|
+
name: irb
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
type: :development
|
48
|
+
prerelease: false
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
- !ruby/object:Gem::Dependency
|
55
|
+
name: pry
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
type: :development
|
62
|
+
prerelease: false
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
41
68
|
description: Measure execution time in Rails console
|
42
69
|
email:
|
43
70
|
- igorkasyanchuk@gmail.com
|
@@ -56,7 +83,6 @@ homepage: https://github.com/igorkasyanchuk
|
|
56
83
|
licenses:
|
57
84
|
- MIT
|
58
85
|
metadata: {}
|
59
|
-
post_install_message:
|
60
86
|
rdoc_options: []
|
61
87
|
require_paths:
|
62
88
|
- lib
|
@@ -71,8 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
71
97
|
- !ruby/object:Gem::Version
|
72
98
|
version: '0'
|
73
99
|
requirements: []
|
74
|
-
rubygems_version: 3.
|
75
|
-
signing_key:
|
100
|
+
rubygems_version: 3.6.3
|
76
101
|
specification_version: 4
|
77
102
|
summary: Measure execution time in Rails console
|
78
103
|
test_files: []
|