diff options
-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 |