mirror of
https://github.com/zhigang1992/RubyMotion.git
synced 2026-04-23 12:27:56 +08:00
31 lines
510 B
Ruby
31 lines
510 B
Ruby
def string_to_i(x)
|
|
small_int = "5"
|
|
large_int = "14213542524"
|
|
small_float = "5.0"
|
|
large_float = "5415125422.0"
|
|
|
|
x.report "to_i with small integer" do
|
|
1000000.times do
|
|
small_int.to_i
|
|
end
|
|
end
|
|
|
|
x.report "to_i with large integer" do
|
|
1000000.times do
|
|
large_int.to_i
|
|
end
|
|
end
|
|
|
|
x.report "to_i with small float" do
|
|
1000000.times do
|
|
small_float.to_i
|
|
end
|
|
end
|
|
|
|
x.report "to_i with large float" do
|
|
1000000.times do
|
|
large_float.to_i
|
|
end
|
|
end
|
|
end
|