forked from JuliaData/DataFrames.jl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add start of a benchmark test (issue JuliaData#40).
- Loading branch information
1 parent
6c44bde
commit 3fb3cee
Showing
1 changed file
with
53 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
srand(1) | ||
N = 10000000 | ||
v = randn(N) | ||
dv = DataVec(v) | ||
dvna = copy(dv) | ||
dvna[randi(N, 10000)] = NA | ||
|
||
f1(v) = sum(v) | ||
f2(v) = sum(nafilter(v)) | ||
f3(v) = sum(naFilter(v)) | ||
f4(v) = mean(v) | ||
f5(v) = mean(nafilter(v)) | ||
f6(v) = mean(naFilter(v)) | ||
|
||
perf_test = Dict() | ||
|
||
perf_test["sum(v): Vector with no NA's"] = () -> f1(v) | ||
perf_test["sum(dv): DataVec with no NA's"] = () -> f1(dv) | ||
perf_test["sum(nafilter(dv)): DataVec with no NA's"] = () -> f2(dv) | ||
perf_test["sum(naFilter(dv)): DataVec with no NA's"] = () -> f3(dv) | ||
|
||
perf_test["sum(dvna): DataVec with NA's"] = () -> f4(dv) | ||
perf_test["sum(nafilter(dvna)): DataVec with NA's"] = () -> f5(dv) | ||
perf_test["sum(naFilter(dvna)): DataVec with NA's"] = () -> f6(dv) | ||
|
||
perf_test["mean(v): Vector with no NA's"] = () -> f4(v) | ||
perf_test["mean(dv): DataVec with no NA's"] = () -> f4(dv) | ||
perf_test["mean(nafilter(dv)): DataVec with no NA's"] = () -> f5(dv) | ||
perf_test["mean(naFilter(dv)): DataVec with no NA's"] = () -> f6(dv) | ||
|
||
perf_test["mean(dvna): DataVec with NA's"] = () -> f4(dv) | ||
perf_test["mean(nafilter(dvna)): DataVec with NA's"] = () -> f5(dv) | ||
perf_test["mean(naFilter(dvna)): DataVec with NA's"] = () -> f6(dv) | ||
|
||
|
||
for (name, f) in perf_test | ||
res = try | ||
@elapsed f() | ||
catch | ||
NA | ||
end | ||
println(name, ", ", res, ", ", strftime("%Y-%m-%d %H:%M:%S",int(time()))) | ||
end | ||
|
||
|
||
# We could write what's above to a file periodically. Then, we could | ||
# write a DataStream to iterate over the files. It would make a good | ||
# test case. | ||
|
||
|
||
|
||
|
||
|