• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang metrics.NewTimer函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/ethereum/go-ethereum/metrics.NewTimer函数的典型用法代码示例。如果您正苦于以下问题:Golang NewTimer函数的具体用法?Golang NewTimer怎么用?Golang NewTimer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了NewTimer函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: Meter

// Meter configures the database metrics collectors and
func (self *LDBDatabase) Meter(prefix string) {
	// Initialize all the metrics collector at the requested prefix
	self.getTimer = metrics.NewTimer(prefix + "user/gets")
	self.putTimer = metrics.NewTimer(prefix + "user/puts")
	self.delTimer = metrics.NewTimer(prefix + "user/dels")
	self.missMeter = metrics.NewMeter(prefix + "user/misses")
	self.readMeter = metrics.NewMeter(prefix + "user/reads")
	self.writeMeter = metrics.NewMeter(prefix + "user/writes")
	self.compTimeMeter = metrics.NewMeter(prefix + "compact/time")
	self.compReadMeter = metrics.NewMeter(prefix + "compact/input")
	self.compWriteMeter = metrics.NewMeter(prefix + "compact/output")

	// Create a quit channel for the periodic collector and run it
	self.quitLock.Lock()
	self.quitChan = make(chan chan error)
	self.quitLock.Unlock()

	go self.meter(3 * time.Second)
}
开发者ID:j4ustin,项目名称:go-ethereum,代码行数:20,代码来源:database.go


示例2:

	"github.com/ethereum/go-ethereum/ethdb"
	"github.com/ethereum/go-ethereum/event"
	"github.com/ethereum/go-ethereum/logger"
	"github.com/ethereum/go-ethereum/logger/glog"
	"github.com/ethereum/go-ethereum/metrics"
	"github.com/ethereum/go-ethereum/pow"
	"github.com/ethereum/go-ethereum/rlp"
	"github.com/ethereum/go-ethereum/trie"
	"github.com/hashicorp/golang-lru"
)

var (
	chainlogger = logger.NewLogger("CHAIN")
	jsonlogger  = logger.NewJsonLogger()

	blockInsertTimer = metrics.NewTimer("chain/inserts")

	ErrNoGenesis = errors.New("Genesis not found in chain")
)

const (
	headerCacheLimit    = 512
	bodyCacheLimit      = 256
	tdCacheLimit        = 1024
	blockCacheLimit     = 256
	maxFutureBlocks     = 256
	maxTimeFutureBlocks = 30
)

type BlockChain struct {
	chainDb      ethdb.Database
开发者ID:General-Beck,项目名称:go-ethereum,代码行数:31,代码来源:blockchain.go


示例3: New

func New(config *Config) (*Ethereum, error) {
	// Bootstrap database
	logger.New(config.DataDir, config.LogFile, config.Verbosity)
	if len(config.LogJSON) > 0 {
		logger.NewJSONsystem(config.DataDir, config.LogJSON)
	}

	// Let the database take 3/4 of the max open files (TODO figure out a way to get the actual limit of the open files)
	const dbCount = 3
	ethdb.OpenFileLimit = 128 / (dbCount + 1)

	newdb := config.NewDB
	if newdb == nil {
		newdb = func(path string) (common.Database, error) { return ethdb.NewLDBDatabase(path) }
	}
	blockDb, err := newdb(filepath.Join(config.DataDir, "blockchain"))
	if err != nil {
		return nil, fmt.Errorf("blockchain db err: %v", err)
	}
	if db, ok := blockDb.(*ethdb.LDBDatabase); ok {
		db.GetTimer = metrics.NewTimer("eth/db/block/user/gets")
		db.PutTimer = metrics.NewTimer("eth/db/block/user/puts")
		db.MissMeter = metrics.NewMeter("eth/db/block/user/misses")
		db.ReadMeter = metrics.NewMeter("eth/db/block/user/reads")
		db.WriteMeter = metrics.NewMeter("eth/db/block/user/writes")
		db.CompTimeMeter = metrics.NewMeter("eth/db/block/compact/time")
		db.CompReadMeter = metrics.NewMeter("eth/db/block/compact/input")
		db.CompWriteMeter = metrics.NewMeter("eth/db/block/compact/output")
	}
	stateDb, err := newdb(filepath.Join(config.DataDir, "state"))
	if err != nil {
		return nil, fmt.Errorf("state db err: %v", err)
	}
	if db, ok := stateDb.(*ethdb.LDBDatabase); ok {
		db.GetTimer = metrics.NewTimer("eth/db/state/user/gets")
		db.PutTimer = metrics.NewTimer("eth/db/state/user/puts")
		db.MissMeter = metrics.NewMeter("eth/db/state/user/misses")
		db.ReadMeter = metrics.NewMeter("eth/db/state/user/reads")
		db.WriteMeter = metrics.NewMeter("eth/db/state/user/writes")
		db.CompTimeMeter = metrics.NewMeter("eth/db/state/compact/time")
		db.CompReadMeter = metrics.NewMeter("eth/db/state/compact/input")
		db.CompWriteMeter = metrics.NewMeter("eth/db/state/compact/output")
	}
	extraDb, err := newdb(filepath.Join(config.DataDir, "extra"))
	if err != nil {
		return nil, fmt.Errorf("extra db err: %v", err)
	}
	if db, ok := extraDb.(*ethdb.LDBDatabase); ok {
		db.GetTimer = metrics.NewTimer("eth/db/extra/user/gets")
		db.PutTimer = metrics.NewTimer("eth/db/extra/user/puts")
		db.MissMeter = metrics.NewMeter("eth/db/extra/user/misses")
		db.ReadMeter = metrics.NewMeter("eth/db/extra/user/reads")
		db.WriteMeter = metrics.NewMeter("eth/db/extra/user/writes")
		db.CompTimeMeter = metrics.NewMeter("eth/db/extra/compact/time")
		db.CompReadMeter = metrics.NewMeter("eth/db/extra/compact/input")
		db.CompWriteMeter = metrics.NewMeter("eth/db/extra/compact/output")
	}
	nodeDb := filepath.Join(config.DataDir, "nodes")

	// Perform database sanity checks
	d, _ := blockDb.Get([]byte("ProtocolVersion"))
	protov := int(common.NewValue(d).Uint())
	if protov != config.ProtocolVersion && protov != 0 {
		path := filepath.Join(config.DataDir, "blockchain")
		return nil, fmt.Errorf("Database version mismatch. Protocol(%d / %d). `rm -rf %s`", protov, config.ProtocolVersion, path)
	}
	saveProtocolVersion(blockDb, config.ProtocolVersion)
	glog.V(logger.Info).Infof("Protocol Version: %v, Network Id: %v", config.ProtocolVersion, config.NetworkId)

	if !config.SkipBcVersionCheck {
		b, _ := blockDb.Get([]byte("BlockchainVersion"))
		bcVersion := int(common.NewValue(b).Uint())
		if bcVersion != config.BlockChainVersion && bcVersion != 0 {
			return nil, fmt.Errorf("Blockchain DB version mismatch (%d / %d). Run geth upgradedb.\n", bcVersion, config.BlockChainVersion)
		}
		saveBlockchainVersion(blockDb, config.BlockChainVersion)
	}
	glog.V(logger.Info).Infof("Blockchain DB Version: %d", config.BlockChainVersion)

	eth := &Ethereum{
		shutdownChan:            make(chan bool),
		databasesClosed:         make(chan bool),
		blockDb:                 blockDb,
		stateDb:                 stateDb,
		extraDb:                 extraDb,
		eventMux:                &event.TypeMux{},
		accountManager:          config.AccountManager,
		DataDir:                 config.DataDir,
		etherbase:               common.HexToAddress(config.Etherbase),
		clientVersion:           config.Name, // TODO should separate from Name
		ethVersionId:            config.ProtocolVersion,
		netVersionId:            config.NetworkId,
		NatSpec:                 config.NatSpec,
		MinerThreads:            config.MinerThreads,
		SolcPath:                config.SolcPath,
		AutoDAG:                 config.AutoDAG,
		GpoMinGasPrice:          config.GpoMinGasPrice,
		GpoMaxGasPrice:          config.GpoMaxGasPrice,
		GpoFullBlockRatio:       config.GpoFullBlockRatio,
		GpobaseStepDown:         config.GpobaseStepDown,
//.........这里部分代码省略.........
开发者ID:haegyung,项目名称:go-ethereum,代码行数:101,代码来源:backend.go


示例4:

//
// go-ethereum is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// go-ethereum is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with go-ethereum.  If not, see <http://www.gnu.org/licenses/>.

// Contains the metrics collected by the fetcher.

package fetcher

import (
	"github.com/ethereum/go-ethereum/metrics"
)

var (
	announceMeter  = metrics.NewMeter("eth/sync/RemoteAnnounces")
	announceTimer  = metrics.NewTimer("eth/sync/LocalAnnounces")
	broadcastMeter = metrics.NewMeter("eth/sync/RemoteBroadcasts")
	broadcastTimer = metrics.NewTimer("eth/sync/LocalBroadcasts")
	discardMeter   = metrics.NewMeter("eth/sync/DiscardedBlocks")
	futureMeter    = metrics.NewMeter("eth/sync/FutureBlocks")
)
开发者ID:ruflin,项目名称:go-ethereum,代码行数:30,代码来源:metrics.go


示例5:

// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.

// Contains the metrics collected by the downloader.

package downloader

import (
	"github.com/ethereum/go-ethereum/metrics"
)

var (
	hashInMeter      = metrics.NewMeter("eth/downloader/hashes/in")
	hashReqTimer     = metrics.NewTimer("eth/downloader/hashes/req")
	hashDropMeter    = metrics.NewMeter("eth/downloader/hashes/drop")
	hashTimeoutMeter = metrics.NewMeter("eth/downloader/hashes/timeout")

	blockInMeter      = metrics.NewMeter("eth/downloader/blocks/in")
	blockReqTimer     = metrics.NewTimer("eth/downloader/blocks/req")
	blockDropMeter    = metrics.NewMeter("eth/downloader/blocks/drop")
	blockTimeoutMeter = metrics.NewMeter("eth/downloader/blocks/timeout")

	headerInMeter      = metrics.NewMeter("eth/downloader/headers/in")
	headerReqTimer     = metrics.NewTimer("eth/downloader/headers/req")
	headerDropMeter    = metrics.NewMeter("eth/downloader/headers/drop")
	headerTimeoutMeter = metrics.NewMeter("eth/downloader/headers/timeout")

	bodyInMeter      = metrics.NewMeter("eth/downloader/bodies/in")
	bodyReqTimer     = metrics.NewTimer("eth/downloader/bodies/req")
开发者ID:Raskal8,项目名称:go-ethereum,代码行数:31,代码来源:metrics.go



注:本文中的github.com/ethereum/go-ethereum/metrics.NewTimer函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang node.Node类代码示例发布时间:2022-05-23
下一篇:
Golang glog.V函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap