using BioSeq
using Benchmark
using DataFrames
ft = Float64[]
gt = Float64[]
nn = Int[]
function percentGC_2(seq::Vector{Nucleotide})
len = length(seq)
sum = 0
for elem in seq
sum += (elem | 32 == 'c') | (elem | 32 =='g')
end
sum/len
end
function compare_with_n()
for n in 30:100:10030
seq = [nucleotide('A');nucleotide('c');nucleotide('t');nucleotide('G')][rand(1:4,n)];
f = ()-> percentGC(seq)
g = ()-> percentGC_2(seq)
@assert f() == g()
cmp = compare([f,g],100);
push!(ft,cmp[1,"Elapsed"])
push!(gt,cmp[2,"Elapsed"])
push!(nn,n)
end
end
compare_with_n()
df = DataFrame(ft,gt,nn)
using Winston
p = FramedPlot()
setattr(p, "xrange", (min(df["x3"]),max(df["x3"])))
setattr(p, "yrange", (min([df["x1"],df["x2"]]),max([df["x1"],df["x2"]])))
setattr(p, "aspect_ratio", 1)
a = Points( df["x3"], df["x1"], "type", "circle" )
setattr(a, "label", "using if")
b = Points( df["x3"], df["x2"] )
setattr(b, "label", "branch predication")
style(b, "type", "filled circle" )
l = Legend( .1, .9, {a,b} )
add( p, a, b, l )
file(p, "bench.png")
julia> file(p,"bench.png")
ERROR: stack overflow
in BitArray at bitarray.jl:32
in trues at bitarray.jl:147
in reshape at abstractarray.jl:143
in project at /home/dzea/.julia/Winston/src/Winston.jl:207 (repeats 34920 times)
in project at /home/dzea/.julia/Winston/src/Winston.jl:247
in make at /home/dzea/.julia/Winston/src/Winston.jl:2864
in render at /home/dzea/.julia/Winston/src/Winston.jl:2933
in render at /home/dzea/.julia/Winston/src/Winston.jl:1471
in compose_interior at /home/dzea/.julia/Winston/src/Winston.jl:1698
in compose at /home/dzea/.julia/Winston/src/Winston.jl:2225
in page_compose at /home/dzea/.julia/Winston/src/Winston.jl:2238
in write_png at /home/dzea/.julia/Winston/src/Winston.jl:2277
in file at /home/dzea/.julia/Winston/src/Winston.jl:2286