From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS4713 221.184.0.0/13 X-Spam-Status: No, score=-3.0 required=3.0 tests=AWL,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id 078ED1F453 for ; Mon, 21 Jan 2019 08:23:32 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 9F9D212150C; Mon, 21 Jan 2019 17:23:28 +0900 (JST) Received: from o1678916x28.outbound-mail.sendgrid.net (o1678916x28.outbound-mail.sendgrid.net [167.89.16.28]) by neon.ruby-lang.org (Postfix) with ESMTPS id 3C5D812150C for ; Mon, 21 Jan 2019 17:23:27 +0900 (JST) Received: by filter0063p3mdw1.sendgrid.net with SMTP id filter0063p3mdw1-13704-5C45817C-A 2019-01-21 08:23:24.233156495 +0000 UTC m=+541068.322032981 Received: from herokuapp.com (ec2-54-205-253-189.compute-1.amazonaws.com [54.205.253.189]) by ismtpd0039p1iad1.sendgrid.net (SG) with ESMTP id M6zyOC_VSwC7jpfzS6kIQA for ; Mon, 21 Jan 2019 08:23:24.194 +0000 (UTC) Date: Mon, 21 Jan 2019 08:23:25 +0000 (UTC) From: mame@ruby-lang.org To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 66652 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 13667 X-Redmine-Issue-Author: burke X-Redmine-Issue-Assignee: mame X-Redmine-Sender: mame X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: ync6xU2WACa70kv/Ymy4QrNMhiuLXJG8OTL2vJD1yS4qJLalACHehTJbSvKLOECnNWz9NI1Ao0Tch7 0XF5VOOZ2hoe/k5L9DBZMeIT0aqT44IDbOREBQHhT/ePLDx5FAz5RyfK8xwIqfoBW0+JxY032WrxUQ yRnum9F4M+qio3Z++ged9frzUgW/NSt+oh4jNhbB6c/C5U8x6ic7YWqqDQ== X-ML-Name: ruby-core X-Mail-Count: 91204 Subject: [ruby-core:91204] [Ruby trunk Feature#13667] Add Coverage.running? to quickly check if Coverage is enabled. X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #13667 has been updated by mame (Yusuke Endoh). Status changed from Feedback to Closed I have forgotten why the status of this ticket is feedback :-) Anyway, it is already released, so there is no change to remove it. Closing. ---------------------------------------- Feature #13667: Add Coverage.running? to quickly check if Coverage is enabled. https://bugs.ruby-lang.org/issues/13667#change-76441 * Author: burke (Burke Libbey) * Status: Closed * Priority: Normal * Assignee: mame (Yusuke Endoh) * 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/