diff options
author | Eric Wong <e@80x24.org> | 2015-01-03 03:28:34 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2015-01-19 09:56:52 +0000 |
commit | 5de3064be43ad6f54df33bcb781b064d83bdd8c8 (patch) | |
tree | ebdedac9bc17387dd8c388370cb76de2b129be2b /bin/dtas-partstats | |
parent | fe577e8d5649521954bb9d73f99dca1b35ce384c (diff) | |
download | dtas-5de3064be43ad6f54df33bcb781b064d83bdd8c8.tar.gz |
This will likely become more available and faster than GNU nproc(1) over time.
Diffstat (limited to 'bin/dtas-partstats')
-rwxr-xr-x | bin/dtas-partstats | 12 |
1 files 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 |