perfetto 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 409c5c5efda9fd49e9865e14b9dcfdd2fda8115af2c88ad551ff2606aee165ec
4
- data.tar.gz: a5d109278ebd31f707a57a0391d41c3ff803268ac9f4171ea229fd11d98f5f0f
3
+ metadata.gz: 6642fce9318093a63a3d77565697ae113b3482aebd5408ec017eaedc6329c359
4
+ data.tar.gz: d92d38f6e5c3a177bc160677bc1c6a7a5334cf899a68724a7ff686266aaef71f
5
5
  SHA512:
6
- metadata.gz: fe779514261dfed2ff2ac54b5ab1e4d5b40985bc508d53e1a5ecb34a6995399fd21ecc26647c87a905fe7177735d098f5fb4aa8184e95be74151bc3a2f4542aa
7
- data.tar.gz: 303f4428d6fa8e78a292e0890caf3d0f9d365767f1bfe790e8166e04cae3f4cd91ab7e858f69914f6c6372adef78c46ba327feb6559761c126ffa56c70a2eeff
6
+ metadata.gz: 12d78ef7a12958fe60be11128014f0327a6aae91543acefdf9c1d473438ad858d79830638699afa80684fedafda2b294f5b6ab486f6ffc9b6166b84c33f91cdf
7
+ data.tar.gz: 471b51999fd8a7b93aa7dc5d2ed3722193f7d4beb02a74db265db437ab220ef99fb62a23ce437afb734c7385757feacf2b7a27a6112ea1fdec73450750a07e1f
data/.rubocop.yml CHANGED
@@ -12,3 +12,7 @@ Style/StringLiteralsInInterpolation:
12
12
 
13
13
  Layout/LineLength:
14
14
  Max: 120
15
+
16
+ require:
17
+ - rubocop-rake
18
+ - rubocop-minitest
data/README.md CHANGED
@@ -1,31 +1,5 @@
1
1
  # Perfetto
2
2
 
3
- TODO: Delete this and the text below, and describe your gem
3
+ ## Visualization
4
4
 
5
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/perfetto`. To experiment with that code, run `bin/console` for an interactive prompt.
6
-
7
- ## Installation
8
-
9
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
10
-
11
- Install the gem and add to the application's Gemfile by executing:
12
-
13
- $ bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
14
-
15
- If bundler is not being used to manage dependencies, install the gem by executing:
16
-
17
- $ gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
18
-
19
- ## Usage
20
-
21
- TODO: Write usage instructions here
22
-
23
- ## Development
24
-
25
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
26
-
27
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
28
-
29
- ## Contributing
30
-
31
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/perfetto.
5
+ https://ui.perfetto.dev/
data/Rakefile CHANGED
@@ -1,12 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "bundler/gem_tasks"
4
- require "minitest/test_task"
5
4
 
5
+ require "rake/extensiontask"
6
+ gemspec = Gem::Specification.load("perfetto.gemspec")
7
+ Rake::ExtensionTask.new("perfetto", gemspec) do |ext|
8
+ ext.ext_dir = "ext/perfetto"
9
+ ext.lib_dir = "lib/perfetto"
10
+ end
11
+
12
+ require "minitest/test_task"
6
13
  Minitest::TestTask.create
7
14
 
8
15
  require "rubocop/rake_task"
9
-
10
16
  RuboCop::RakeTask.new
11
17
 
12
18
  task default: %i[test rubocop]
@@ -0,0 +1,189 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright (c) 2017, The Android Open Source Project
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+
183
+ Unless required by applicable law or agreed to in writing, software
184
+ distributed under the License is distributed on an "AS IS" BASIS,
185
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
186
+ See the License for the specific language governing permissions and
187
+ limitations under the License.
188
+
189
+
@@ -0,0 +1,11 @@
1
+ # Google Perfetto Tracing SDK
2
+
3
+ `sdk.h` and `sdk.cc` are copied from the Google Perfetto Tracing SDK.
4
+
5
+ ## Version
6
+
7
+ v40.0
8
+
9
+ ## Reference
10
+
11
+ https://perfetto.dev/docs/instrumentation/tracing-sdk
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "mkmf"
4
+
5
+ # Rubocop
6
+ # rubocop:disable Style/GlobalVars
7
+ $CXXFLAGS += " -std=c++17 -O3 -pthread"
8
+ $CFLAGS += " -std=c11 -O3 -pthread"
9
+ # rubocop:enable Style/GlobalVars
10
+
11
+ create_makefile "perfetto/perfetto_native"
@@ -0,0 +1,92 @@
1
+ #include <ruby.h>
2
+
3
+ #include "perfetto_internal.h"
4
+
5
+ /* Modules */
6
+ static VALUE rb_mPerfetto;
7
+
8
+ /* Methods */
9
+
10
+ static VALUE rb_perfetto_start_tracing(VALUE self, VALUE buffer_size_kb)
11
+ {
12
+ return perfetto_start_tracing(NUM2UINT(buffer_size_kb)) ? Qtrue : Qfalse;
13
+ }
14
+
15
+ static VALUE rb_perfetto_stop_tracing(VALUE self, VALUE output_file)
16
+ {
17
+ return perfetto_stop_tracing(StringValuePtr(output_file)) ? Qtrue : Qfalse;
18
+ }
19
+
20
+ static VALUE rb_perfetto_trace_event_begin(VALUE self, VALUE category, VALUE name)
21
+ {
22
+ perfetto_trace_event_begin(StringValuePtr(category), StringValuePtr(name));
23
+ return Qnil;
24
+ }
25
+
26
+ static VALUE rb_perfetto_trace_event_end(VALUE self, VALUE category)
27
+ {
28
+ perfetto_trace_event_end(StringValuePtr(category));
29
+ return Qnil;
30
+ }
31
+
32
+ static VALUE rb_perfetto_trace_counter_i64(VALUE self, VALUE category, VALUE name, VALUE value)
33
+ {
34
+ perfetto_trace_counter_i64(StringValuePtr(category), StringValuePtr(name), NUM2LL(value));
35
+ return Qnil;
36
+ }
37
+
38
+ static VALUE rb_perfetto_trace_counter_double(VALUE self, VALUE category, VALUE name, VALUE value)
39
+ {
40
+ perfetto_trace_counter_double(StringValuePtr(category), StringValuePtr(name), NUM2DBL(value));
41
+ return Qnil;
42
+ }
43
+
44
+ static VALUE rb_perfetto_trace_event_instant(VALUE self, VALUE category, VALUE name)
45
+ {
46
+ perfetto_trace_event_instant(StringValuePtr(category), StringValuePtr(name));
47
+ return Qnil;
48
+ }
49
+
50
+ static VALUE rb_perfetto_trace_event_instant_with_debug_info(VALUE self, VALUE category, VALUE name, VALUE debug_info_key, VALUE debug_info_value)
51
+ {
52
+ perfetto_trace_event_instant_with_debug_info(StringValuePtr(category), StringValuePtr(name), StringValuePtr(debug_info_key), StringValuePtr(debug_info_value));
53
+ return Qnil;
54
+ }
55
+
56
+ static VALUE rb_perfetto_trace_event_begin_with_debug_info(VALUE self, VALUE category, VALUE name, VALUE debug_info_key, VALUE debug_info_value)
57
+ {
58
+ perfetto_trace_event_begin_with_debug_info(StringValuePtr(category), StringValuePtr(name), StringValuePtr(debug_info_key), StringValuePtr(debug_info_value));
59
+ return Qnil;
60
+ }
61
+
62
+ static VALUE rb_perfetto_trace_counter(VALUE self, VALUE category, VALUE name, VALUE value)
63
+ {
64
+ if (TYPE(value) == T_FIXNUM)
65
+ {
66
+ return rb_perfetto_trace_counter_i64(self, category, name, value);
67
+ }
68
+ else if (TYPE(value) == T_FLOAT)
69
+ {
70
+ return rb_perfetto_trace_counter_double(self, category, name, value);
71
+ }
72
+ else
73
+ {
74
+ rb_raise(rb_eTypeError, "Value must be a Fixnum or Float");
75
+ }
76
+ }
77
+
78
+ void Init_perfetto_native(void)
79
+ {
80
+ rb_mPerfetto = rb_define_module("Perfetto");
81
+
82
+ rb_define_module_function(rb_mPerfetto, "start_tracing", rb_perfetto_start_tracing, 1);
83
+ rb_define_module_function(rb_mPerfetto, "stop_tracing", rb_perfetto_stop_tracing, 1);
84
+ rb_define_module_function(rb_mPerfetto, "trace_event_begin", rb_perfetto_trace_event_begin, 2);
85
+ rb_define_module_function(rb_mPerfetto, "trace_event_end", rb_perfetto_trace_event_end, 1);
86
+ rb_define_module_function(rb_mPerfetto, "trace_counter_i64", rb_perfetto_trace_counter_i64, 3);
87
+ rb_define_module_function(rb_mPerfetto, "trace_counter_double", rb_perfetto_trace_counter_double, 3);
88
+ rb_define_module_function(rb_mPerfetto, "trace_counter", rb_perfetto_trace_counter, 3);
89
+ rb_define_module_function(rb_mPerfetto, "trace_event_instant", rb_perfetto_trace_event_instant, 2);
90
+ rb_define_module_function(rb_mPerfetto, "trace_event_instant_with_debug_info", rb_perfetto_trace_event_instant_with_debug_info, 4);
91
+ rb_define_module_function(rb_mPerfetto, "trace_event_begin_with_debug_info", rb_perfetto_trace_event_begin_with_debug_info, 4);
92
+ }
@@ -0,0 +1,149 @@
1
+ #include "sdk.h"
2
+
3
+ #include <memory>
4
+ #include <atomic>
5
+ #include <mutex>
6
+ #include <fstream>
7
+ #include <vector>
8
+ #include <string>
9
+
10
+ #include "perfetto_internal.h"
11
+
12
+ PERFETTO_DEFINE_CATEGORIES();
13
+ PERFETTO_TRACK_EVENT_STATIC_STORAGE();
14
+
15
+ static struct GlobalState
16
+ {
17
+ std::unique_ptr<perfetto::TracingSession> tracing_session;
18
+ bool is_initialized;
19
+ bool is_tracing;
20
+ std::mutex mutex;
21
+
22
+ GlobalState() : tracing_session(nullptr), is_initialized(false), mutex()
23
+ {
24
+ }
25
+ } global_state;
26
+
27
+ extern "C"
28
+ {
29
+
30
+ static inline void perfetto_initialize()
31
+ {
32
+ perfetto::TracingInitArgs args;
33
+ args.backends = perfetto::kInProcessBackend;
34
+ perfetto::Tracing::Initialize(args);
35
+ perfetto::TrackEvent::Register();
36
+ global_state.is_initialized = true;
37
+ }
38
+
39
+ bool perfetto_start_tracing(const uint32_t buffer_size_kb)
40
+ {
41
+ std::lock_guard<std::mutex> lock(global_state.mutex);
42
+
43
+ if (global_state.is_tracing)
44
+ {
45
+ return false;
46
+ }
47
+
48
+ if (!global_state.is_initialized)
49
+ {
50
+ perfetto_initialize();
51
+ }
52
+
53
+ if (buffer_size_kb == 0)
54
+ {
55
+ return false;
56
+ }
57
+
58
+ perfetto::TraceConfig trace_config;
59
+ trace_config.add_buffers()->set_size_kb(buffer_size_kb);
60
+ auto *ds_config = trace_config.add_data_sources()->mutable_config();
61
+ ds_config->set_name("track_event");
62
+
63
+ auto tracing_session = perfetto::Tracing::NewTrace();
64
+ tracing_session->Setup(trace_config);
65
+ tracing_session->StartBlocking();
66
+
67
+ global_state.tracing_session = std::move(tracing_session);
68
+ global_state.is_tracing = true;
69
+ return true;
70
+ }
71
+
72
+ bool perfetto_stop_tracing(const char *const output_file)
73
+ {
74
+ std::lock_guard<std::mutex> lock(global_state.mutex);
75
+ if (!global_state.is_initialized || !global_state.is_tracing)
76
+ {
77
+ return false;
78
+ }
79
+
80
+ perfetto::TrackEvent::Flush();
81
+ global_state.tracing_session->StopBlocking();
82
+ std::vector<char> trace_data(global_state.tracing_session->ReadTraceBlocking());
83
+ global_state.tracing_session.reset();
84
+ global_state.is_tracing = false;
85
+
86
+ try
87
+ {
88
+ std::ofstream output(output_file, std::ios::out | std::ios::binary);
89
+ output.write(trace_data.data(), trace_data.size());
90
+ output.close();
91
+ }
92
+ catch (std::exception &e)
93
+ {
94
+ return false;
95
+ }
96
+
97
+ return true;
98
+ }
99
+
100
+ void perfetto_trace_event_begin(const char *const category, const char *const name)
101
+ {
102
+ perfetto::DynamicCategory dynamic_category(category);
103
+ perfetto::DynamicString dynamic_name(name);
104
+ TRACE_EVENT_BEGIN(dynamic_category, dynamic_name);
105
+ }
106
+
107
+ void perfetto_trace_event_end(const char *const category)
108
+ {
109
+ perfetto::DynamicCategory dynamic_category(category);
110
+ TRACE_EVENT_END(dynamic_category);
111
+ }
112
+
113
+ void perfetto_trace_counter_i64(const char *const category, const char *const name, const int64_t value)
114
+ {
115
+ perfetto::DynamicCategory dynamic_category(category);
116
+ perfetto::DynamicString dynamic_name(name);
117
+ TRACE_COUNTER(dynamic_category, perfetto::CounterTrack(name), value);
118
+ }
119
+
120
+ void perfetto_trace_counter_double(const char *const category, const char *const name, const double value)
121
+ {
122
+ perfetto::DynamicCategory dynamic_category(category);
123
+ TRACE_COUNTER(dynamic_category, perfetto::CounterTrack(name), value);
124
+ }
125
+
126
+ void perfetto_trace_event_instant(const char *const category, const char *const name)
127
+ {
128
+ perfetto::DynamicCategory dynamic_category(category);
129
+ perfetto::DynamicString dynamic_name(name);
130
+ TRACE_EVENT_INSTANT(dynamic_category, dynamic_name);
131
+ }
132
+
133
+ void perfetto_trace_event_instant_with_debug_info(const char *const category, const char *const name, const char *const debug_info_key, const char *const debug_info_value)
134
+ {
135
+ perfetto::DynamicCategory dynamic_category(category);
136
+ perfetto::DynamicString dynamic_name(name);
137
+ TRACE_EVENT_INSTANT(dynamic_category, dynamic_name,
138
+ debug_info_key, debug_info_value);
139
+ }
140
+
141
+ void perfetto_trace_event_begin_with_debug_info(const char *const category, const char *const name, const char *const debug_info_key, const char *const debug_info_value)
142
+ {
143
+ perfetto::DynamicCategory dynamic_category(category);
144
+ perfetto::DynamicString dynamic_name(name);
145
+ TRACE_EVENT_BEGIN(dynamic_category, dynamic_name,
146
+ debug_info_key, debug_info_value);
147
+ }
148
+
149
+ } // extern "C"
@@ -0,0 +1,36 @@
1
+ #ifndef _RUBY_PERFETTO_INTERNAL_H_
2
+ #define _RUBY_PERFETTO_INTERNAL_H_
3
+
4
+ #ifdef __cplusplus
5
+ extern "C"
6
+ {
7
+ #endif
8
+
9
+ #include <stdint.h>
10
+ #include <string.h>
11
+ #include <stdlib.h>
12
+
13
+ /* C Interface */
14
+
15
+ bool perfetto_start_tracing(const uint32_t buffer_size_kb);
16
+
17
+ bool perfetto_stop_tracing(const char *const output_file);
18
+
19
+ void perfetto_trace_event_begin(const char *const category, const char *const name);
20
+
21
+ void perfetto_trace_event_end(const char *const category);
22
+
23
+ void perfetto_trace_counter_i64(const char *const category, const char *const name, const int64_t value);
24
+
25
+ void perfetto_trace_counter_double(const char *const category, const char *const name, const double value);
26
+
27
+ void perfetto_trace_event_instant(const char *const category, const char *const name);
28
+
29
+ void perfetto_trace_event_instant_with_debug_info(const char *const category, const char *const name, const char *const debug_info_key, const char *const debug_info_value);
30
+
31
+ void perfetto_trace_event_begin_with_debug_info(const char *const category, const char *const name, const char *const debug_info_key, const char *const debug_info_value);
32
+ #ifdef __cplusplus
33
+ }
34
+ #endif
35
+
36
+ #endif // _RUBY_PERFETTO_INTERNAL_H_