Last active
November 11, 2019 07:49
-
-
Save ohta-rh/8fffb2ae778e4135d4f195fb7baf42d7 to your computer and use it in GitHub Desktop.
rubyでコアを使い切ってみる
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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