execution_time 0.1.4 → 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 +14 -2
- data/lib/execution_time/railtie.rb +0 -2
- data/lib/execution_time/version.rb +1 -1
- data/lib/execution_time.rb +2 -2
- metadata +3 -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,6 +1,6 @@
|
|
1
1
|
# ExecutionTime
|
2
2
|
|
3
|
-
[](https://buymeacoffee.com/igorkasyanchuk)
|
4
4
|
|
5
5
|
Monitor execution time and other metrics directly in `rails console`, similar to what you see after each request.
|
6
6
|
|
@@ -19,7 +19,7 @@ If you want to measure few lines of code just wrap it with `begin/end`:
|
|
19
19
|
[4] pry(main)* User.first.first_name.size
|
20
20
|
[4] pry(main)* a = User.count + 1
|
21
21
|
[4] pry(main)* b = User.second.last_name.size
|
22
|
-
[4] pry(main)* end
|
22
|
+
[4] pry(main)* end
|
23
23
|
User Load (0.4ms) SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT $1 [["LIMIT", 1]]
|
24
24
|
(3.6ms) SELECT COUNT(*) FROM "users"
|
25
25
|
User Load (0.3ms) SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT $1 OFFSET $2 [["LIMIT", 1], ["OFFSET", 1]]
|
@@ -35,6 +35,15 @@ Add this line to your application's Gemfile:
|
|
35
35
|
gem 'execution_time'
|
36
36
|
```
|
37
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
|
+
|
38
47
|
## First run
|
39
48
|
|
40
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.
|
@@ -53,9 +62,12 @@ You are welcome to contribute.
|
|
53
62
|
## Contributos
|
54
63
|
|
55
64
|
- https://github.com/nbulaj
|
65
|
+
- https://github.com/ruban-thilak
|
56
66
|
|
57
67
|
## License
|
58
68
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
59
69
|
|
60
70
|
[<img src="https://github.com/igorkasyanchuk/rails_time_travel/blob/main/docs/more_gems.png?raw=true"
|
61
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
|
|
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
|
@@ -84,7 +83,6 @@ homepage: https://github.com/igorkasyanchuk
|
|
84
83
|
licenses:
|
85
84
|
- MIT
|
86
85
|
metadata: {}
|
87
|
-
post_install_message:
|
88
86
|
rdoc_options: []
|
89
87
|
require_paths:
|
90
88
|
- lib
|
@@ -99,8 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
99
97
|
- !ruby/object:Gem::Version
|
100
98
|
version: '0'
|
101
99
|
requirements: []
|
102
|
-
rubygems_version: 3.
|
103
|
-
signing_key:
|
100
|
+
rubygems_version: 3.6.3
|
104
101
|
specification_version: 4
|
105
102
|
summary: Measure execution time in Rails console
|
106
103
|
test_files: []
|