Skip to content

Instantly share code, notes, and snippets.

@ohta-rh
Last active November 11, 2019 07:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ohta-rh/8fffb2ae778e4135d4f195fb7baf42d7 to your computer and use it in GitHub Desktop.
Save ohta-rh/8fffb2ae778e4135d4f195fb7baf42d7 to your computer and use it in GitHub Desktop.
rubyでコアを使い切ってみる
HOGE = (1..10000000).to_a
EXPECTED_ORDER = 1000
NUM_OF_CORES = 4
PROCESSING_ORDER = EXPECTED_ORDER / NUM_OF_CORES
def sum
PROCESSING_ORDER.times do
p HOGE.sum
end
end
def main
NUM_OF_CORES.times do
fork do
sum
end
end
end
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment