execution_time 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/README.md +11 -2
- data/lib/execution_time.rb +13 -0
- data/lib/execution_time/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f18a74e2fd925985154a51464fd05101bbaa23f1d3e4ba3b66f80a7d3a88173
|
4
|
+
data.tar.gz: f201b8e48c7dd34b32df183ffbdce19ee95f047e1f4a66d182a923fcc13952cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 334c7b1d8d7bfa62d43f54b05b3366389540a6076babb5a448036ccf82609bd54e60ead4cbce9a118b6a26ef9f5375cd4cfb22b9ebb46271adaf2f188652edcf
|
7
|
+
data.tar.gz: 741ce85c6c3768b77edf9aa1643c6af001b5be60c508d9f51594d72a83f430dd0f3de9c41010e4775a3b364a0cb58c41d70b55fa436adebeda78aa207370fbd9
|
data/README.md
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
# ExecutionTime
|
2
2
|
|
3
|
-
|
3
|
+
Monitor execution time and other metrics directly in `rails console`, similar to what you see after each request.
|
4
4
|
|
5
5
|
`[METRICS] Completed in 908.3ms | Allocations: 2894 | ActiveRecord: 0.9ms (queries: 13)`
|
6
6
|
|
7
|
+
<img src="https://github.com/igorkasyanchuk/execution_time/blob/master/docs/execution_time_new.gif?raw=true" width="90%" />
|
8
|
+
|
7
9
|
## Usage
|
8
10
|
|
9
11
|
Just add this gem to the Gemfile and start `rails c`. After this try to do something like `User.first`.
|
@@ -20,7 +22,14 @@ gem 'execution_time'
|
|
20
22
|
|
21
23
|
## First run
|
22
24
|
|
23
|
-
Sometime you can see that there are more SQL queries or allocated objects because Ruby just loading objects in memory or verifying connection to the DB.
|
25
|
+
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.
|
26
|
+
|
27
|
+
## How to disable/enable metrics output in the console
|
28
|
+
|
29
|
+
If you need to disable gem in the console you can do it by `ExecutionTime.disable!`. And later enable with `ExecutionTime.enable!`.
|
30
|
+
|
31
|
+
By default gem is enabled.
|
32
|
+
|
24
33
|
|
25
34
|
## Contributing
|
26
35
|
|
data/lib/execution_time.rb
CHANGED
@@ -1,6 +1,17 @@
|
|
1
1
|
require "execution_time/railtie"
|
2
2
|
|
3
3
|
module ExecutionTime
|
4
|
+
mattr_accessor :enabled
|
5
|
+
@@enabled = true
|
6
|
+
|
7
|
+
def ExecutionTime.enable!
|
8
|
+
@@enabled = true
|
9
|
+
end
|
10
|
+
|
11
|
+
def ExecutionTime.disable!
|
12
|
+
@@enabled = false
|
13
|
+
end
|
14
|
+
|
4
15
|
class AppMetrics
|
5
16
|
@@counter = 0
|
6
17
|
|
@@ -32,6 +43,8 @@ module ExecutionTime
|
|
32
43
|
|
33
44
|
class Measurer
|
34
45
|
def Measurer.watch
|
46
|
+
return yield unless ExecutionTime.enabled
|
47
|
+
|
35
48
|
AppMetrics.reset
|
36
49
|
|
37
50
|
start = Time.now
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Kasyanchuk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-06-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|