Skip to content

Commit

Permalink
Corrected edgeindex test
Browse files Browse the repository at this point in the history
  • Loading branch information
fredericlemoine committed Oct 31, 2016
1 parent 5dc7812 commit 3330383
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions tests/edgeindex_benchmark.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package tests

import (
"github.com/fredericlemoine/gotree/io/utils"
"github.com/fredericlemoine/gotree/tree"
"sync"
"testing"
)

// Benchmark for reading 1000 bootstrap trees for example
// With gunzip
func BenchmarkEdgeIndex(b *testing.B) {

for n := 0; n < b.N; n++ {

reftree, err := utils.ReadRefTree("data/benchmark_ref.nw.gz")
if err != nil {
b.Error(err.Error)
}

intrees := make(chan tree.Trees, 15)
/* Read ref tree(s) */
go func() {
if _, err := utils.ReadCompTrees("data/benchmark_boot.nw.gz", intrees); err != nil {
b.Error(err.Error)
}
}()
var wg sync.WaitGroup
edgeindex := tree.NewEdgeIndex(24000, .75)
for cpu := 0; cpu < 4; cpu++ {
wg.Add(1)
go func() {
for tr := range intrees {
edges := tr.Tree.Edges()
for _, e := range edges {
edgeindex.AddEdgeCount(e)
}
}
wg.Done()
}()
}
wg.Wait()

for _, e := range reftree.Edges() {
edgeindex.Value(e)
}
}
}

0 comments on commit 3330383

Please sign in to comment.