vernier 0.1.1 → 0.2.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 +19 -5
- data/Rakefile +4 -0
- data/examples/threaded_http_requests.rb +38 -0
- data/ext/vernier/ruby_type_names.h +44 -0
- data/ext/vernier/vernier.cc +1218 -114
- data/lib/vernier/collector.rb +52 -0
- data/lib/vernier/marker.rb +38 -0
- data/lib/vernier/output/firefox.rb +365 -0
- data/lib/vernier/output/top.rb +30 -0
- data/lib/vernier/version.rb +1 -1
- data/lib/vernier.rb +167 -5
- data/vernier.gemspec +1 -1
- metadata +10 -6
- data/Gemfile.lock +0 -24
- data/ext/vernier/stack.hh +0 -78
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dcfae18cfffd67e1e8a52c0c9de2654e7523b674d492964dfa3447c967d981e3
|
4
|
+
data.tar.gz: 4ff2a81a37d19f974914a0ff3fa28937302a636721b8732f7e7b282f895db9f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd4e4f001047bb3f20c9c0670339747b9e29abf6e44bcd77dbb38fcf7c16f42d33eef893045ab7a899b155d9b98765950e91af79864234a2d66243490d367d49
|
7
|
+
data.tar.gz: 14cecc8aa1058b4e38f130bed6ec1d43e8a59a636c125862ef6c61df13f885e1d76b1a142d0fa8fab16ea6bfee2642b7cd606bb562020f800ce3518b2c7fac2c
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Vernier
|
2
2
|
|
3
|
-
Experimental Ruby
|
3
|
+
Experimental next-generation Ruby profiler.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -10,16 +10,23 @@ gem 'vernier'
|
|
10
10
|
|
11
11
|
## Usage
|
12
12
|
|
13
|
-
|
13
|
+
### Retained memory
|
14
|
+
|
15
|
+
Record a flamegraph of all **retained** allocations from loading `irb`.
|
14
16
|
|
15
17
|
```
|
16
|
-
ruby -r vernier -e 'Vernier.trace_retained(out: "
|
18
|
+
ruby -r vernier -e 'Vernier.trace_retained(out: "irb_profile.json") { require "irb" }'
|
17
19
|
```
|
18
20
|
|
19
|
-
The output can then be viewed in
|
21
|
+
The output can then be viewed in the [Firefox Profiler (demo)](https://share.firefox.dev/3DhLsFa)
|
22
|
+
|
23
|
+
![Screenshot 2023-07-16 at 21-06-19 Ruby_Vernier – 1970-01-01 12 00 00 a m UTC – Firefox Profiler](https://github.com/jhawthorn/vernier/assets/131752/9ca0b593-70fb-4c8b-aed9-cb33e0e0bc06)
|
20
24
|
|
21
|
-
|
25
|
+
### Time
|
22
26
|
|
27
|
+
```
|
28
|
+
Vernier.trace(out: "time_profile.json") { some_slow_method }
|
29
|
+
```
|
23
30
|
|
24
31
|
## Development
|
25
32
|
|
@@ -31,6 +38,13 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
31
38
|
|
32
39
|
Bug reports and pull requests are welcome on GitHub at https://github.com/jhawthorn/vernier. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/jhawthorn/vernier/blob/main/CODE_OF_CONDUCT.md).
|
33
40
|
|
41
|
+
### Resources
|
42
|
+
|
43
|
+
* https://profiler.firefox.com/docs/#/
|
44
|
+
* https://github.com/firefox-devtools/profiler/tree/main/docs-developer
|
45
|
+
* https://github.com/tmm1/stackprof
|
46
|
+
* https://github.com/ruby/ruby/pull/5500
|
47
|
+
|
34
48
|
## License
|
35
49
|
|
36
50
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
CHANGED
@@ -0,0 +1,38 @@
|
|
1
|
+
require "vernier"
|
2
|
+
|
3
|
+
Vernier.trace(out: "http_requests.json") do
|
4
|
+
|
5
|
+
require "net/http"
|
6
|
+
require "uri"
|
7
|
+
require "openssl"
|
8
|
+
|
9
|
+
urls = Queue.new
|
10
|
+
received = Queue.new
|
11
|
+
|
12
|
+
threads = 2.times.map do
|
13
|
+
Thread.new do
|
14
|
+
while url = urls.pop
|
15
|
+
uri = URI.parse(url)
|
16
|
+
response = Net::HTTP.get_response(uri)
|
17
|
+
|
18
|
+
received << [url, response.code]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
Thread.new do
|
24
|
+
threads.each(&:join)
|
25
|
+
received.close
|
26
|
+
end
|
27
|
+
|
28
|
+
urls << "http://example.com"
|
29
|
+
urls << "https://www.johnhawthorn.com"
|
30
|
+
urls << "https://tenderlovemaking.com/"
|
31
|
+
urls.close
|
32
|
+
|
33
|
+
while x = received.pop
|
34
|
+
url, code = *x
|
35
|
+
puts "#{url} #{code}"
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
#pragma once
|
2
|
+
|
3
|
+
inline const char *
|
4
|
+
ruby_object_type_name(VALUE obj) {
|
5
|
+
enum ruby_value_type type = rb_type(obj);
|
6
|
+
|
7
|
+
#define TYPE_CASE(x) case (x): return (#x)
|
8
|
+
|
9
|
+
// Many of these are impossible, but it's easier to just include them
|
10
|
+
switch (type) {
|
11
|
+
TYPE_CASE(T_OBJECT);
|
12
|
+
TYPE_CASE(T_CLASS);
|
13
|
+
TYPE_CASE(T_MODULE);
|
14
|
+
TYPE_CASE(T_FLOAT);
|
15
|
+
TYPE_CASE(T_STRING);
|
16
|
+
TYPE_CASE(T_REGEXP);
|
17
|
+
TYPE_CASE(T_ARRAY);
|
18
|
+
TYPE_CASE(T_HASH);
|
19
|
+
TYPE_CASE(T_STRUCT);
|
20
|
+
TYPE_CASE(T_BIGNUM);
|
21
|
+
TYPE_CASE(T_FILE);
|
22
|
+
TYPE_CASE(T_DATA);
|
23
|
+
TYPE_CASE(T_MATCH);
|
24
|
+
TYPE_CASE(T_COMPLEX);
|
25
|
+
TYPE_CASE(T_RATIONAL);
|
26
|
+
|
27
|
+
TYPE_CASE(T_NIL);
|
28
|
+
TYPE_CASE(T_TRUE);
|
29
|
+
TYPE_CASE(T_FALSE);
|
30
|
+
TYPE_CASE(T_SYMBOL);
|
31
|
+
TYPE_CASE(T_FIXNUM);
|
32
|
+
TYPE_CASE(T_UNDEF);
|
33
|
+
|
34
|
+
TYPE_CASE(T_IMEMO);
|
35
|
+
TYPE_CASE(T_NODE);
|
36
|
+
TYPE_CASE(T_ICLASS);
|
37
|
+
TYPE_CASE(T_ZOMBIE);
|
38
|
+
TYPE_CASE(T_MOVED);
|
39
|
+
|
40
|
+
default:
|
41
|
+
return "unknown type";
|
42
|
+
}
|
43
|
+
#undef TYPE_CASE
|
44
|
+
}
|