Last active
August 29, 2015 14:12
-
-
Save tanmaykm/fe61b0becbed0f5a32c6 to your computer and use it in GitHub Desktop.
maybeint and maybefloat tests
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
julia> time_int64(10^8, "23423432423") | |
maybeint64: | |
elapsed time: 9.7062274 seconds (0 bytes allocated) | |
int64: | |
elapsed time: 12.49588723 seconds (0 bytes allocated) | |
julia> time_float32(10^8, "23423432423.234234324324") | |
maybefloat32: | |
elapsed time: 7.356884435 seconds (0 bytes allocated) | |
float32: | |
elapsed time: 9.496854888 seconds (1600000000 bytes allocated, 6.78% gc time) | |
julia> time_float64(10^8, "23423432423.234234324324") | |
maybefloat64: | |
elapsed time: 15.34450968 seconds (0 bytes allocated) | |
float64: | |
elapsed time: 16.635047832 seconds (1600000000 bytes allocated, 3.56% gc time) |
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
function time_int64(N::Int64, s::AbstractString) | |
println("maybeint64:") | |
gc() | |
@time for i in 1:N | |
f1 = maybeint(Int64, s) | |
end | |
println("int64:") | |
gc() | |
@time for i in 1:N | |
f2 = int64(s) | |
end | |
end | |
function time_float64(N::Int64, s::AbstractString) | |
println("maybefloat64:") | |
gc() | |
@time for i in 1:N | |
f1 = maybefloat64(s) | |
end | |
println("float64:") | |
gc() | |
@time for i in 1:N | |
f2 = float64(s) | |
end | |
end | |
function time_float32(N::Int64, s::AbstractString) | |
gc() | |
println("maybefloat32:") | |
@time for i in 1:N | |
f1::Nullable{Float32} = maybefloat32(s) | |
end | |
gc() | |
println("float32:") | |
@time for i in 1:N | |
f2 = float32(s) | |
end | |
end | |
time_int64(10^8, "23423432423") | |
time_float32(10^8, "23423432423.234234324324") | |
time_float64(10^8, "23423432423.234234324324") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment