[Groonga-commit] ranguba/rroonga at d52fdef [master] Split method

Back to archive index

Kouhei Sutou null+****@clear*****
Thu Jan 8 11:18:33 JST 2015


Kouhei Sutou	2015-01-08 11:18:33 +0900 (Thu, 08 Jan 2015)

  New Revision: d52fdef6057d54beccfa164b593a93c26855691b
  https://github.com/ranguba/rroonga/commit/d52fdef6057d54beccfa164b593a93c26855691b

  Message:
    Split method

  Modified files:
    build/windows/Vagrantfile

  Modified: build/windows/Vagrantfile (+8 -8)
===================================================================
--- build/windows/Vagrantfile    2015-01-08 11:14:41 +0900 (8a3ca20)
+++ build/windows/Vagrantfile    2015-01-08 11:18:33 +0900 (5accb85)
@@ -4,18 +4,17 @@
 # Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
 VAGRANTFILE_API_VERSION = "2"
 
-def use_cpu_nums
+def available_n_cpus
   proc_file = "/proc/cpuinfo"
-  use_cpus = 1
   if File.exist?(proc_file)
-    cpu_nums = `cat #{proc_file} |grep processor|wc -l`
+    File.readlines(proc_file).grep(/\Aprocessor\b/).size
   elsif RUBY_PLATFORM =~ /darwin/
-    cpu_nums = `sysctl -n hw.ncpu`
+    `sysctl -n hw.ncpu`.to_i
   elsif RUBY_PLATFORM =~ /mswin|msys|mingw|cygwin|bccwin|wince|emc/
-    cpu_nums = `echo %NUMBER_OF_PROCESSORS%`
+    `echo %NUMBER_OF_PROCESSORS%`.to_i
+  else
+    1
   end
-  use_cpus = cpu_nums.to_i / 2 if cpu_nums.to_i >=2
-  use_cpus
 end
 
 Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
@@ -24,7 +23,8 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
 
   config.vm.provider("virtualbox") do |vb|
     vb.gui = false
-    used_n_cpus = use_cpu_nums
+    used_n_cpus = available_n_cpus
+    used_n_cpus /= 2 if used_n_cpus >= 2
     vb.customize ["modifyvm", :id, "--cpus", use_n_cpus.to_s]
     vb.customize ["modifyvm", :id, "--memory", "2048"]
   end
-------------- next part --------------
HTML����������������������������...
Descargar 



More information about the Groonga-commit mailing list
Back to archive index