Skip to content

Commit

Permalink
Add start of a benchmark test (issue JuliaData#40).
Browse files Browse the repository at this point in the history
  • Loading branch information
powerdistribution committed Aug 11, 2012
1 parent 6c44bde commit 3fb3cee
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions test/perf/datavec.jl
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.





0 comments on commit 3fb3cee

Please sign in to comment.