From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) 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=BAYES_00,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_MED,SPF_PASS,T_DKIM_INVALID, T_RP_MATCHES_RCVD shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id 9D9461FA7B for ; Mon, 19 Jun 2017 19:39:33 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id AF64F120766; Tue, 20 Jun 2017 04:39: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 F1C86120765 for ; Tue, 20 Jun 2017 04:39:26 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=sendgrid.me; h=from:to:references:subject:mime-version:content-type:content-transfer-encoding:list-id; s=smtpapi; bh=O5CNhmz6KH2wfDPY76mM6DwlHSU=; b=LMTPA4HwBhf7GYra7L uaY/tLXv4DSCgWLqEoBTs7+/FXjthkG/IczixH6KG+1ggP8HJs9kAAuSTqeJiS6F m/qOsVpn9VPJUoCwUTd4IRNlQy3tMyTikpVnsYqvKu+WVOKFEWk8Y7p0JAuqz8VH 3g3BuktG+OFrB5dalLcxEN944= Received: by filter1097p1mdw1.sendgrid.net with SMTP id filter1097p1mdw1-30887-59482863-8 2017-06-19 19:39:15.093904085 +0000 UTC Received: from herokuapp.com (ec2-54-221-151-206.compute-1.amazonaws.com [54.221.151.206]) by ismtpd0005p1iad1.sendgrid.net (SG) with ESMTP id A8AWUVv4RfG93auoTCdZ-g for ; Mon, 19 Jun 2017 19:39:15.034 +0000 (UTC) Date: Mon, 19 Jun 2017 19:39:15 +0000 From: burke@libbey.me To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 56755 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 13667 X-Redmine-Issue-Author: burke X-Redmine-Sender: burke 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/Ymy4QrNMhiuLXJG8OTL2vJD1yS4H8fYJyWyowqCmPtYEIS7AK5ZV8r0KRXhM35 +MaTABfCU3lu3rODXWFFz2BhePrMXztmQH95HrXayU8YvNiZsJU6MGaXXTcnvTnoReN6Gt/WLCsa/S RXuzcvGR7bnxwHBCYS/u3/XUJHQlYqJ8rUdu X-ML-Name: ruby-core X-Mail-Count: 81726 Subject: [ruby-core:81726] [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 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/