Add rudimentary tests
This commit is contained in:
parent
ea492c9ab9
commit
bf23b2c175
7
.gitattributes
vendored
7
.gitattributes
vendored
@ -1,6 +1 @@
|
||||
examples/AB->ABBBBB.txt filter=lfs diff=lfs merge=lfs -text
|
||||
examples/AB->ABBBBBBB.txt filter=lfs diff=lfs merge=lfs -text
|
||||
examples/ABAB->ABAB.txt filter=lfs diff=lfs merge=lfs -text
|
||||
examples/ABAB->ABC.txt filter=lfs diff=lfs merge=lfs -text
|
||||
examples/AB->AB.txt filter=lfs diff=lfs merge=lfs -text
|
||||
examples/AB->ABBB.txt filter=lfs diff=lfs merge=lfs -text
|
||||
examples/*.txt filter=lfs diff=lfs merge=lfs -text
|
||||
|
@ -1,4 +1,4 @@
|
||||
name = "metagraph_optimization"
|
||||
name = "MetagraphOptimization"
|
||||
uuid = "3e869610-d48d-4942-ba70-c1b702a33ca4"
|
||||
authors = ["Anton Reinhard <anton.reinhard@proton.me>"]
|
||||
version = "0.1.0"
|
||||
@ -9,3 +9,9 @@ DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
|
||||
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
|
||||
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
|
||||
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
|
||||
|
||||
[extras]
|
||||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
|
||||
|
||||
[targets]
|
||||
test = ["Test"]
|
||||
|
@ -1,28 +1,33 @@
|
||||
using metagraph_optimization
|
||||
using MetagraphOptimization
|
||||
using BenchmarkTools
|
||||
using Base
|
||||
using Base.Filesystem
|
||||
|
||||
function bench_txt(filepath::String)
|
||||
function bench_txt(filepath::String, bench::Bool = true)
|
||||
name = basename(filepath)
|
||||
name, _ = splitext(name)
|
||||
|
||||
filepath = joinpath(@__DIR__, filepath)
|
||||
|
||||
println(name, ":")
|
||||
g = import_txt(filepath)
|
||||
print(g)
|
||||
println(" Graph size in memory: ", bytes_to_human_readable(Base.summarysize(g)))
|
||||
@btime import_txt($filepath)
|
||||
println()
|
||||
|
||||
if (bench)
|
||||
@btime import_txt($filepath)
|
||||
println()
|
||||
end
|
||||
end
|
||||
|
||||
function main()
|
||||
bench_txt("examples/AB->AB.txt")
|
||||
bench_txt("examples/AB->ABBB.txt")
|
||||
bench_txt("examples/AB->ABBBBB.txt")
|
||||
bench_txt("examples/AB->ABBBBBBB.txt")
|
||||
#bench_txt("examples/AB->ABBBBBBBBB.txt")
|
||||
bench_txt("examples/ABAB->ABAB.txt")
|
||||
bench_txt("examples/ABAB->ABC.txt")
|
||||
function import_bench()
|
||||
bench_txt("AB->AB.txt")
|
||||
bench_txt("AB->ABBB.txt")
|
||||
bench_txt("AB->ABBBBB.txt")
|
||||
bench_txt("AB->ABBBBBBB.txt")
|
||||
bench_txt("AB->ABBBBBBBBB.txt", false)
|
||||
bench_txt("ABAB->ABAB.txt")
|
||||
bench_txt("ABAB->ABC.txt")
|
||||
end
|
||||
|
||||
main()
|
||||
import_bench()
|
||||
|
@ -1,4 +1,4 @@
|
||||
module metagraph_optimization
|
||||
module MetagraphOptimization
|
||||
import Base.show
|
||||
import Base.==
|
||||
import Base.in
|
||||
@ -23,4 +23,4 @@ export ==, in, show
|
||||
|
||||
export bytes_to_human_readable
|
||||
|
||||
end # module metagraph_optimization
|
||||
end # module MetagraphOptimization
|
13
test/known_graphs.jl
Normal file
13
test/known_graphs.jl
Normal file
@ -0,0 +1,13 @@
|
||||
using MetagraphOptimization
|
||||
using Test
|
||||
|
||||
function test_known_graphs()
|
||||
|
||||
g_ABAB = import_txt(joinpath(@__DIR__, "..", "examples", "AB->AB.txt"))
|
||||
props = graph_properties(g_ABAB)
|
||||
|
||||
@test length(g_ABAB.nodes) == 34
|
||||
@test props.compute_effort == 185
|
||||
@test props.data == 102
|
||||
|
||||
end
|
6
test/runtests.jl
Normal file
6
test/runtests.jl
Normal file
@ -0,0 +1,6 @@
|
||||
using MetagraphOptimization
|
||||
using Test
|
||||
|
||||
include("known_graphs.jl")
|
||||
|
||||
test_known_graphs()
|
Loading…
x
Reference in New Issue
Block a user