cirron 0.2.2
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 +7 -0
- data/LICENSE +21 -0
- data/README.md +42 -0
- data/cirron.gemspec +42 -0
- data/lib/apple_arm_events.h +902 -0
- data/lib/cirron.rb +2 -0
- data/lib/cirronlib.cpp +321 -0
- data/lib/collector.rb +70 -0
- data/lib/tracer.rb +162 -0
- metadata +96 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ff54dda8d0986886acb138298e91096d18acfd9cdb0adb927b13613d6f0eca17
|
4
|
+
data.tar.gz: 7fd5cb27f2834094f1d3941d1c24aca63a4195835f98fc133d064664db4ec662
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0af236106e911b520dea0dab38194652c1e3ef3f5ccfa33f46f261dd17a8807a15501f136f0a02cc9aa22ab3c09ae7f44088aa41c2451d09fdcda0b288ceab8d
|
7
|
+
data.tar.gz: adfaa9a35e9c2d107c675a9beadfc72c65612d02fcb57d7bc76103b4f050872b06c9e3b73edd43745f5c392a607c182ae08d4075e4ea092bbcc16d02abbaaf7a
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2024 Matt Stuchlik
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
==
|
2
|
+
# Cirron
|
3
|
+
|
4
|
+
Cirron measures a piece of Ruby code and report back several performance counters: CPU instruction count, branch misses, page faults and time spent measuring. It uses the Linux perf events interface or @ibireme's [KPC demo](https://gist.github.com/ibireme/173517c208c7dc333ba962c1f0d67d12) on OSX.
|
5
|
+
|
6
|
+
It can also trace syscalls using `strace`, Linux only!
|
7
|
+
|
8
|
+
## Prerequisites
|
9
|
+
|
10
|
+
- Linux with perf events support / Apple ARM OSX
|
11
|
+
- C++
|
12
|
+
- Ruby 3.x
|
13
|
+
|
14
|
+
## Usage
|
15
|
+
|
16
|
+
### Performance Counters
|
17
|
+
```
|
18
|
+
from cirron import Collector
|
19
|
+
|
20
|
+
# Start collecting performance metrics
|
21
|
+
with Collector() as collector:
|
22
|
+
# Your code here
|
23
|
+
# ...
|
24
|
+
|
25
|
+
# Retrieve the metrics
|
26
|
+
print(collector.counters)
|
27
|
+
```
|
28
|
+
|
29
|
+
### Syscalls
|
30
|
+
```
|
31
|
+
from cirron import Tracer, to_tef
|
32
|
+
|
33
|
+
with Tracer() as tracer:
|
34
|
+
# Your code here
|
35
|
+
# ...
|
36
|
+
|
37
|
+
# Stop collecting and retrieve the trace
|
38
|
+
print(tracer.trace)
|
39
|
+
|
40
|
+
# Save the trace for ingesting to Perfetto
|
41
|
+
open("/tmp/trace", "w").write(to_tef(trace))
|
42
|
+
```
|
data/cirron.gemspec
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'fileutils'
|
5
|
+
require 'pathname'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = "cirron"
|
9
|
+
spec.version = "0.2.2"
|
10
|
+
spec.authors = ["Matt Stuchlik"]
|
11
|
+
spec.email = ["matej.stuchlik@gmail.com"]
|
12
|
+
|
13
|
+
spec.summary = "Cirron measures how many CPU instructions and system calls a piece of Ruby code executes."
|
14
|
+
spec.description = File.read(File.join(File.dirname(__FILE__), "README.md"))
|
15
|
+
spec.homepage = "https://github.com/s7nfo/Cirron"
|
16
|
+
spec.license = "MIT"
|
17
|
+
spec.required_ruby_version = ">= 3.0.0"
|
18
|
+
|
19
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
20
|
+
spec.metadata["source_code_uri"] = "https://github.com/s7nfo/Cirron"
|
21
|
+
|
22
|
+
spec.files = [
|
23
|
+
"lib/apple_arm_events.h",
|
24
|
+
"lib/cirron.rb",
|
25
|
+
"lib/cirronlib.cpp",
|
26
|
+
"lib/collector.rb",
|
27
|
+
"lib/tracer.rb",
|
28
|
+
"README.md",
|
29
|
+
"LICENSE",
|
30
|
+
"cirron.gemspec"
|
31
|
+
]
|
32
|
+
|
33
|
+
spec.bindir = "exe"
|
34
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
35
|
+
spec.require_paths = ["lib"]
|
36
|
+
|
37
|
+
# Uncomment to register a new dependency of your gem
|
38
|
+
# spec.add_dependency "example-gem", "~> 1.0"
|
39
|
+
|
40
|
+
# For more information and examples about making a new gem, check out our
|
41
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
42
|
+
end
|