Skip to content
Snippets Groups Projects
Unverified Commit 5c646b97 authored by Luca Moser's avatar Luca Moser
Browse files

print DBStats() func ints

parent 68626bb8
No related branches found
No related tags found
No related merge requests found
...@@ -2,6 +2,7 @@ package tangle ...@@ -2,6 +2,7 @@ package tangle
import ( import (
"container/list" "container/list"
"fmt"
"runtime" "runtime"
"time" "time"
...@@ -66,6 +67,8 @@ func New(store kvstore.KVStore) (result *Tangle) { ...@@ -66,6 +67,8 @@ func New(store kvstore.KVStore) (result *Tangle) {
Events: *newEvents(), Events: *newEvents(),
} }
result.DBStats()
result.solidifierWorkerPool.Tune(runtime.GOMAXPROCS(0)) result.solidifierWorkerPool.Tune(runtime.GOMAXPROCS(0))
return return
} }
...@@ -147,7 +150,9 @@ func (tangle *Tangle) Prune() error { ...@@ -147,7 +150,9 @@ func (tangle *Tangle) Prune() error {
// DBStats returns the number of solid messages and total number of messages in the database, furthermore the average time it takes to solidify messages. // DBStats returns the number of solid messages and total number of messages in the database, furthermore the average time it takes to solidify messages.
func (tangle *Tangle) DBStats() (solidCount int, messageCount int, avgSolidificationTime float64) { func (tangle *Tangle) DBStats() (solidCount int, messageCount int, avgSolidificationTime float64) {
var sumSolidificationTime time.Duration var sumSolidificationTime time.Duration
var iterations int
tangle.messageMetadataStorage.ForEach(func(key []byte, cachedObject objectstorage.CachedObject) bool { tangle.messageMetadataStorage.ForEach(func(key []byte, cachedObject objectstorage.CachedObject) bool {
iterations++
cachedObject.Consume(func(object objectstorage.StorableObject) { cachedObject.Consume(func(object objectstorage.StorableObject) {
msgMetaData := object.(*MessageMetadata) msgMetaData := object.(*MessageMetadata)
messageCount++ messageCount++
...@@ -160,6 +165,7 @@ func (tangle *Tangle) DBStats() (solidCount int, messageCount int, avgSolidifica ...@@ -160,6 +165,7 @@ func (tangle *Tangle) DBStats() (solidCount int, messageCount int, avgSolidifica
return true return true
}) })
avgSolidificationTime = float64(sumSolidificationTime.Milliseconds()) / float64(solidCount) avgSolidificationTime = float64(sumSolidificationTime.Milliseconds()) / float64(solidCount)
fmt.Println("solid", solidCount, "message", messageCount, "iterations", iterations)
return return
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment