Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Store options given to collector in the result #30

Closed
dalehamel opened this issue Oct 19, 2023 · 1 comment · Fixed by #76
Closed

Store options given to collector in the result #30

dalehamel opened this issue Oct 19, 2023 · 1 comment · Fixed by #76
Assignees
Labels
C Likely requires C/C++ changes enhancement New feature or request good first issue Good for newcomers

Comments

@dalehamel
Copy link
Contributor

Eg:

vernier/ext/vernier/vernier.cc

Lines 1482 to 1503 in dc16edf

static VALUE collector_new(VALUE self, VALUE mode, VALUE options) {
BaseCollector *collector;
if (mode == sym("retained")) {
collector = new RetainedCollector();
} else if (mode == sym("custom")) {
collector = new CustomCollector();
} else if (mode == sym("wall")) {
VALUE intervalv = rb_hash_aref(options, sym("interval"));
TimeStamp interval;
if (NIL_P(intervalv)) {
interval = TimeStamp::from_microseconds(500);
} else {
interval = TimeStamp::from_microseconds(NUM2UINT(intervalv));
}
collector = new TimeCollector(interval);
} else {
rb_raise(rb_eArgError, "invalid mode");
}
VALUE obj = TypedData_Wrap_Struct(self, &rb_collector_type, collector);
rb_funcall(obj, rb_intern("initialize"), 1, mode);
return obj;
}

Can the mode and interval passed to the collector be added to Result (perhaps in Result.meta hash?) so that we can determine after the fact what the parameters were for the profile?

So something like:

collector = Vernier::Collector.new(:wall, interval: 1000)
collector.start
foo
result = collector.stop
assert_equal :wall, result.meta[:mode] 
assert_equal 1000, result.meta[:interval]
@jhawthorn jhawthorn added enhancement New feature or request good first issue Good for newcomers C Likely requires C/C++ changes labels Nov 12, 2023
@jhawthorn jhawthorn changed the title [feat] Can we store basic config params somewhere on the Result object? Store options given to collector in the result May 8, 2024
@joshuay03 joshuay03 self-assigned this Jun 10, 2024
@joshuay03
Copy link
Collaborator

#76

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C Likely requires C/C++ changes enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants