Created
April 3, 2015 08:15
-
-
Save seak0503/6060726a6e05a60d7168 to your computer and use it in GitHub Desktop.
文字列、数値、シンボルのベンチマーク比較
This file contains 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
require "benchmark" | |
str_time = Benchmark.realtime do | |
10000000.times { "abcde" == "abcde" } | |
end | |
int_time = Benchmark.realtime do | |
10000000.times { 12345 == 12345 } | |
end | |
sym_time = Benchmark.realtime do | |
10000000.times { :abcde == :abcde } | |
end | |
puts("文字列の場合の処理時間: #{str_time}") | |
puts("数値型の場合の処理時間: #{int_time}") | |
puts("シンボルの場合の処理時間: #{sym_time}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment