-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5dc7812
commit 3330383
Showing
1 changed file
with
48 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,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) | ||
} | ||
} | ||
} |