Skip to content

Commit 0750500

Browse files
authored
Merge pull request #47 from tk3369/tk/migrate0.7
Julia 0.7 support
2 parents 57bfdcc + 56c7dc2 commit 0750500

File tree

8 files changed

+93
-21
lines changed

8 files changed

+93
-21
lines changed

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ os:
55
- osx
66
julia:
77
- 0.6
8+
- 0.7
89
- nightly
910
notifications:
1011
email: false

deps/build.jl

-9
This file was deleted.

src/CIDict.jl

+8-3
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,14 @@ Base.haskey(d::CIDict, s::String) = haskey(d.dct, lcase(s))
3535
Base.keys(d::CIDict) = keys(d.dct)
3636
Base.values(d::CIDict) = values(d.dct)
3737

38-
Base.start(d::CIDict) = start(d.dct)
39-
Base.next(d::CIDict, i::Int) = next(d.dct, i)
40-
Base.done(d::CIDict, i::Int) = done(d.dct, i)
38+
@static if VERSION.minor < 7
39+
Base.start(d::CIDict) = start(d.dct)
40+
Base.next(d::CIDict, i::Int) = next(d.dct, i)
41+
Base.done(d::CIDict, i::Int) = done(d.dct, i)
42+
else
43+
Base.iterate(d::CIDict) = iterate(d.dct)
44+
Base.iterate(d::CIDict, i) = iterate(d.dct, i)
45+
end
4146

4247
Base.length(d::CIDict) = length(d.dct)
4348

src/SASLib.jl

+4-3
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ read the entire file content. When called again, fetch the next `nrows` rows.
7474
function read(handler::Handler, nrows=0)
7575
# println("Reading $(handler.config.filename)")
7676
elapsed = @elapsed result = read_chunk(handler, nrows)
77-
elapsed = round(elapsed, 5)
77+
# TODO base keyword arg should not be needed due to Compat.jl issue #567
78+
elapsed = Compat.round(elapsed; digits = 5, base = 10)
7879
println1(handler, "Read $(handler.config.filename) with size $(size(result, 1)) x $(size(result, 2)) in $elapsed seconds")
7980
return result
8081
end
@@ -983,7 +984,7 @@ end
983984

984985
# convert Float64 value into Date object
985986
function date_from_float(x::Vector{Float64})
986-
@compat v = Vector{Union{Date, Missing}}(uninitialized, length(x))
987+
@compat v = Vector{Union{Date, Missing}}(undef, length(x))
987988
for i in 1:length(x)
988989
v[i] = isnan(x[i]) ? missing : (sas_date_origin + Dates.Day(round(Int64, x[i])))
989990
end
@@ -992,7 +993,7 @@ end
992993

993994
# convert Float64 value into DateTime object
994995
function datetime_from_float(x::Vector{Float64})
995-
@compat v = Vector{Union{DateTime, Missing}}(uninitialized, length(x))
996+
@compat v = Vector{Union{DateTime, Missing}}(undef, length(x))
996997
for i in 1:length(x)
997998
v[i] = isnan(x[i]) ? missing : (sas_datetime_origin + Dates.Second(round(Int64, x[i])))
998999
end

src/constants.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,6 @@ const VENDOR_SAS = 0x01
213213
const FALLBACK_ENCODING = "UTF-8"
214214
const ENCODINGS_OK_WITH_BASE_TRANSCODER = [ "UTF-8" , "US-ASCII" ]
215215

216-
@compat const REGULAR_STR_ARRAY(n) = Array{String}(uninitialized, n)
216+
@compat const REGULAR_STR_ARRAY(n) = Array{String}(undef, n)
217217
const EMPTY_STRING = ""
218218

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Performance Comparison (0.7.0-beta vs 0.6.3)
2+
3+
## Small Data Set
4+
5+
Reading data_pandas/productsales.sas7bdat (140K) is 12% faster in v0.7.
6+
7+
v0.7
8+
```
9+
julia> @benchmark readsas("data_pandas/productsales.sas7bdat", verbose_level = 0)
10+
BenchmarkTools.Trial:
11+
memory estimate: 1.01 MiB
12+
allocs estimate: 14727
13+
--------------
14+
minimum time: 1.748 ms (0.00% GC)
15+
median time: 1.843 ms (0.00% GC)
16+
mean time: 2.027 ms (5.61% GC)
17+
maximum time: 58.967 ms (96.56% GC)
18+
--------------
19+
samples: 2458
20+
evals/sample: 1
21+
```
22+
23+
v0.6.3
24+
```
25+
julia> @benchmark readsas("data_pandas/productsales.sas7bdat", verbose_level = 0)
26+
BenchmarkTools.Trial:
27+
memory estimate: 1.07 MiB
28+
allocs estimate: 18505
29+
--------------
30+
minimum time: 1.987 ms (0.00% GC)
31+
median time: 2.150 ms (0.00% GC)
32+
mean time: 2.367 ms (5.56% GC)
33+
maximum time: 10.130 ms (70.77% GC)
34+
--------------
35+
samples: 2108
36+
evals/sample: 1
37+
```
38+
39+
## Larger Data Set
40+
41+
Reading data_AHS2013/topical.sas7bdat (14 MB) is 18% faster in v0.7.
42+
43+
v0.7
44+
```
45+
julia> @benchmark readsas("data_AHS2013/topical.sas7bdat", verbose_level = 0) seconds=60
46+
BenchmarkTools.Trial:
47+
memory estimate: 649.63 MiB
48+
allocs estimate: 19011924
49+
--------------
50+
minimum time: 1.959 s (10.46% GC)
51+
median time: 2.042 s (12.78% GC)
52+
mean time: 2.061 s (12.59% GC)
53+
maximum time: 2.348 s (12.17% GC)
54+
--------------
55+
samples: 30
56+
evals/sample: 1
57+
```
58+
59+
v0.6.3
60+
```
61+
julia> @benchmark readsas("data_AHS2013/topical.sas7bdat", verbose_level = 0) seconds=60
62+
BenchmarkTools.Trial:
63+
memory estimate: 632.36 MiB
64+
allocs estimate: 18653427
65+
--------------
66+
minimum time: 2.391 s (10.82% GC)
67+
median time: 2.520 s (13.07% GC)
68+
mean time: 2.524 s (12.84% GC)
69+
maximum time: 2.638 s (12.87% GC)
70+
--------------
71+
samples: 24
72+
evals/sample: 1
73+
```

test/perf_test1.jl

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
using BenchmarkTools
2+
using InteractiveUtils
3+
using Printf
24

35
if length(ARGS) != 2
46
println("Usage: $PROGRAM_FILE <filename> <count>")
@@ -8,9 +10,8 @@ end
810
versioninfo()
911
println()
1012

11-
tic()
12-
using SASLib
13-
@printf "Loaded library in %.3f seconds\n" toq()
13+
load_time = @elapsed using SASLib
14+
@printf "Loaded library in %.3f seconds\n" load_time
1415

1516
b = @benchmark readsas($ARGS[1], verbose_level=0) samples=parse(Int, ARGS[2])
1617
display(b)

test/runtests.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Base.convert(::Type{YearStr}, v::Float64) = YearStr(string(round(Int, v)))
2424
x = SASLib.ObjectPool{String, UInt8}(default, 5)
2525
@test length(x) == 5
2626
@test size(x) == (5, )
27-
@test endof(x) == 5
27+
@test @compat lastindex(x) == 5
2828
@test count(v -> v == default, x) == 5
2929
@test count(v -> v === default, x) == 5
3030
@test map(v -> "x$v", x) == [ "x", "x", "x", "x", "x" ]
@@ -239,7 +239,7 @@ Base.convert(::Type{YearStr}, v::Float64) = YearStr(string(round(Int, v)))
239239
# Deal with v0.6/v0.7 difference
240240
# v0.6 shows Missings.Missing
241241
# v0.7 shows Missing
242-
ty(x) = replace(x, "Missings.", "")
242+
ty(x) = replace(x, "Missings." => "")
243243

244244
# convenient comparison routine since v0.6/v0.7 displays different order
245245
same(x,y) = sort(ty.(string.(collect(x)))) == sort(ty.(string.(collect(y))))

0 commit comments

Comments
 (0)