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, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,SPF_PASS,T_DKIM_INVALID 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 EA94D208E3 for ; Sat, 2 Sep 2017 14:12:02 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 65953120912; Sat, 2 Sep 2017 23:11:59 +0900 (JST) Received: from o1678948x4.outbound-mail.sendgrid.net (o1678948x4.outbound-mail.sendgrid.net [167.89.48.4]) by neon.ruby-lang.org (Postfix) with ESMTPS id 84717120911 for ; Sat, 2 Sep 2017 23:11:57 +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=UuL+Y25CFEsp3eTwaqpgmbUP2q4=; b=nJUOUuyvJHQJAE7TyW yPWHjcA5jvkh9FhxbVffQyvocujXp0DgXNMjwieS836qeelN/X2qw45q4murqq90 3H4ExOfh0AAaqNq2aSIZDh7g62PnGhuHD0XBl7eKiKO8cnpFPEednwB5ta1iEGWg YdkvJnnEc+kMFy7pT5uLN17Is= Received: by filter0019p3las1.sendgrid.net with SMTP id filter0019p3las1-14687-59AABC29-17 2017-09-02 14:11:53.871432398 +0000 UTC Received: from herokuapp.com (ec2-54-158-154-37.compute-1.amazonaws.com [54.158.154.37]) by ismtpd0002p1iad1.sendgrid.net (SG) with ESMTP id K0SuYFDDTs-fqWqA_PAC4A for ; Sat, 02 Sep 2017 14:11:53.660 +0000 (UTC) Date: Sat, 02 Sep 2017 14:11:54 +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: 57690 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/Ymy4QrNMhiuLXJG8OTL2vJD1yS4R0xkZRjWnGFMcvjobIbcCxRMU8izxvHC4mA pH3fCrGmSsvQfHknUixiOXQu4ZOBEcMPeA132bOq/UuRLu5jN22RJW83aMf9j3+FYUGdCeQJCwWuxu p0r2GllC94bTQ19PrHAecWHMBJNQPQnoffZEaW4+64a9F9VBxjZ6jQrbTA== X-ML-Name: ruby-core X-Mail-Count: 82635 Subject: [ruby-core:82635] [Ruby trunk Feature#13667][Feedback] 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 Closed to Feedback I applied the patch proposed. After that, however, I'm now considering reverting it. I noticed that this feature may be dangerous. By using this, we can easily write a program that changes its behavior only under coverage measurement. It brings difficulties to testing with coverage measurement. I don't see such a bad program released into the wild. Could you elaborate your use case that beats the disadvantage? If any, I will remain the feature, but otherwise, I will revert it. ---------------------------------------- Feature #13667: Add Coverage.running? to quickly check if Coverage is enabled. https://bugs.ruby-lang.org/issues/13667#change-66462 * Author: burke (Burke Libbey) * Status: Feedback * 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/