github.com/fibonacci-chain/fbc@v0.0.0-20231124064014-c7636198c1e9/libs/system/trace/persist/statistics.go (about)

     1  package persist
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/fibonacci-chain/fbc/libs/system/trace"
     7  )
     8  
     9  var stats *statistics
    10  
    11  func init() {
    12  	stats = &statistics{
    13  		BaseStatistics: trace.NewSummary(),
    14  	}
    15  }
    16  
    17  type statistics struct {
    18  	trace.BaseStatistics
    19  }
    20  
    21  func GetStatistics() *statistics {
    22  	return stats
    23  }
    24  
    25  func (s *statistics) Format() string {
    26  	var res string
    27  	for _, tag := range s.GetTags() {
    28  		res += fmt.Sprintf("%s<%dms>, ", tag, s.GetValue(tag)/1e6)
    29  	}
    30  
    31  	return res[0 : len(res)-2]
    32  }