From: burke@libbey.me
To: ruby-core@ruby-lang.org
Subject: [ruby-core:81726] [Ruby trunk Feature#13667] Add Coverage.running? to quickly check if Coverage is enabled.
Date: Mon, 19 Jun 2017 19:39:15 +0000 [thread overview]
Message-ID: <redmine.issue-13667.20170619193914.184af6edf88c80de@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-13667.20170619193914@ruby-lang.org
Issue #13667 has been reported by burke (Burke Libbey).
----------------------------------------
Feature #13667: Add Coverage.running? to quickly check if Coverage is enabled.
https://bugs.ruby-lang.org/issues/13667
* Author: burke (Burke Libbey)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
----------------------------------------
Since we can't `RubyVM::InstructionSequence#to_binary` when `Coverage` is running, it is useful to be able to ask ruby if coverage is active.
This is possible with `Coverage.peek_result`, but not efficient, since it involves quite a bit of data copying.
I've used the private symbol `rb_get_coverages` in [bootsnap](https://github.com/Shopify/bootsnap/pull/63) for now but this feels worth exposing publicly.
```
> Benchmark.realtime { 100.times{ Coverage.peek_result } }
=> 1.3659249999909662
> Benchmark.realtime { 100.times{ Bootsnap::CompileCache::Native.coverage_running? } }
=> 5.099998088553548e-05
```
Example usage:
```
class RubyVM::InstructionSequence
def load_iseq(path)
return nil if defined?(Coverage) && Coverage.running?
# ...
end
end
```
---Files--------------------------------
0001-Add-Coverage.enabled-to-quickly-check-if-coverage-is.patch (1.97 KB)
--
https://bugs.ruby-lang.org/
next parent reply other threads:[~2017-06-19 19:39 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <redmine.issue-13667.20170619193914@ruby-lang.org>
2017-06-19 19:39 ` burke [this message]
2017-06-20 0:08 ` [ruby-core:81729] [Ruby trunk Feature#13667][Assigned] Add Coverage.running? to quickly check if Coverage is enabled hsbt
2017-08-25 0:56 ` [ruby-core:82462] [Ruby trunk Feature#13667] " mame
2017-08-25 1:04 ` [ruby-core:82465] " spiketeika
2017-09-02 14:11 ` [ruby-core:82635] [Ruby trunk Feature#13667][Feedback] " mame
2019-01-21 8:23 ` [ruby-core:91204] [Ruby trunk Feature#13667] " mame
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.ruby-lang.org/en/community/mailing-lists/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=redmine.issue-13667.20170619193914.184af6edf88c80de@ruby-lang.org \
--to=ruby-core@ruby-lang.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).