From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS22989 208.118.235.0/24 X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 shortcircuit=no autolearn=unavailable version=3.3.2 X-Original-To: dtas-all@80x24.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 66F1C1F494 for ; Sat, 17 Jan 2015 11:49:46 +0000 (UTC) Received: from localhost ([::1]:58906 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YCRsv-0003Iv-Tb for dtas-all@80x24.org; Sat, 17 Jan 2015 06:49:45 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43209) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YCRsq-0003Hl-Vl for dtas-all@nongnu.org; Sat, 17 Jan 2015 06:49:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YCRsi-0006q9-Ul for dtas-all@nongnu.org; Sat, 17 Jan 2015 06:49:40 -0500 Received: from dcvr.yhbt.net ([64.71.152.64]:45033) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YCRsi-0006q2-QL for dtas-all@nongnu.org; Sat, 17 Jan 2015 06:49:32 -0500 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 780FF1F456; Sat, 17 Jan 2015 11:49:29 +0000 (UTC) From: Eric Wong To: Subject: [PATCH 1/5] partstats: use Etc.nprocessors on Ruby 2.2+ Date: Sat, 17 Jan 2015 11:49:18 +0000 Message-Id: <1421495362-31430-2-git-send-email-e@80x24.org> X-Mailer: git-send-email 2.3.0.rc0.45.ga7910d6 In-Reply-To: <1421495362-31430-1-git-send-email-e@80x24.org> References: <1421495362-31430-1-git-send-email-e@80x24.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 64.71.152.64 Cc: e@80x24.org X-BeenThere: dtas-all@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dtas-all-bounces+dtas-all=80x24.org@nongnu.org Sender: dtas-all-bounces+dtas-all=80x24.org@nongnu.org This will likely become more available and faster than GNU nproc(1) over time. --- bin/dtas-partstats | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/bin/dtas-partstats b/bin/dtas-partstats index 7026b2e..fd9bb0b 100755 --- a/bin/dtas-partstats +++ b/bin/dtas-partstats @@ -9,9 +9,15 @@ require 'dtas/partstats' infile = ARGV[0] or abort "usage: #$0 INFILE" ps = DTAS::PartStats.new(infile) -opts = { - jobs: `nproc 2>/dev/null || echo 2`.to_i -} + +def nproc + require 'etc' + Etc.nprocessors +rescue NoMethodError + `nproc 2>/dev/null || echo 2`.to_i +end + +opts = { jobs: nproc } stats = ps.run(opts) headers = ps.key_idx.to_a -- EW