63 Star 183 Fork 3

Gitee 极速下载/hyperledger-fabric

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/hyperledger/fabric
克隆/下载
conf.go 3.99 KB
一键复制 编辑 原始数据 按行查看 历史
/*
Copyright IBM Corp. 2017 All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package experiments
import (
"flag"
"github.com/hyperledger/fabric/test/tools/LTE/chainmgmt"
)
// txConf captures the transaction related configurations
// numTotalTxs specifies the total transactions that should be executed and committed across chains
// numParallelTxsPerChain specifies the parallel transactions on each of the chains
// numWritesPerTx specifies the number of keys to write in each transaction
// numReadsPerTx specifies the number of keys to read in each transaction, Note: this parameters
// match the numWritesPerTx for normal benchmarks. This can be set to zero to make batch update measurements.
type txConf struct {
numTotalTxs int
numParallelTxsPerChain int
numWritesPerTx int
numReadsPerTx int
}
// dataConf captures the data related configurations
// numKVs specifies number of total key-values across chains
// kvSize specifies the size of a key-value (in bytes)
// useJSON specifies if the value stored is in JSON format
type dataConf struct {
numKVs int
kvSize int
useJSON bool
}
// configuration captures all the configurations for an experiment
// For details of individual configuration, see comments on the specific type
type configuration struct {
chainMgrConf *chainmgmt.ChainMgrConf
batchConf *chainmgmt.BatchConf
dataConf *dataConf
txConf *txConf
}
// defaultConf returns a configuration loaded with default values
func defaultConf() *configuration {
conf := &configuration{}
conf.chainMgrConf = &chainmgmt.ChainMgrConf{DataDir: "/tmp/fabric/ledgerPerfTests", NumChains: 1}
conf.batchConf = &chainmgmt.BatchConf{BatchSize: 10, SignBlock: false}
conf.txConf = &txConf{numTotalTxs: 100000, numParallelTxsPerChain: 100, numWritesPerTx: 4, numReadsPerTx: 4}
conf.dataConf = &dataConf{numKVs: 100000, kvSize: 200, useJSON: false}
return conf
}
// emptyConf returns a an empty configuration (with nested structure only)
func emptyConf() *configuration {
conf := &configuration{}
conf.chainMgrConf = &chainmgmt.ChainMgrConf{}
conf.batchConf = &chainmgmt.BatchConf{}
conf.txConf = &txConf{}
conf.dataConf = &dataConf{}
return conf
}
// confFromTestParams consumes the parameters passed by an experiment
// and returns the configuration loaded with the parsed param values
func confFromTestParams(testParams []string) *configuration {
conf := emptyConf()
flags := flag.NewFlagSet("testParams", flag.ExitOnError)
// chainMgrConf
dataDir := flags.String("DataDir", conf.chainMgrConf.DataDir, "Dir for ledger data")
numChains := flags.Int("NumChains", conf.chainMgrConf.NumChains, "Number of chains")
// txConf
numParallelTxsPerChain := flags.Int("NumParallelTxPerChain",
conf.txConf.numParallelTxsPerChain, "Number of TxSimulators concurrently on each chain")
numTotalTxs := flags.Int("NumTotalTx",
conf.txConf.numTotalTxs, "Number of total transactions")
numWritesPerTx := flags.Int("NumWritesPerTx",
conf.txConf.numWritesPerTx, "number of keys written in each Tx")
numReadsPerTx := flags.Int("NumReadsPerTx",
conf.txConf.numReadsPerTx, "number of keys to read in each Tx")
// batchConf
batchSize := flags.Int("BatchSize",
conf.batchConf.BatchSize, "number of Txs in each batch")
// dataConf
numKVs := flags.Int("NumKVs",
conf.dataConf.numKVs, "the keys are named as key_0, key_1,... upto key_(NumKVs-1)")
kvSize := flags.Int("KVSize",
conf.dataConf.kvSize, "size of the key-value in bytes")
useJSON := flags.Bool("UseJSONFormat", conf.dataConf.useJSON, "should CouchDB use JSON for values")
flags.Parse(testParams)
conf.chainMgrConf.DataDir = *dataDir
conf.chainMgrConf.NumChains = *numChains
conf.txConf.numParallelTxsPerChain = *numParallelTxsPerChain
conf.txConf.numTotalTxs = *numTotalTxs
conf.txConf.numWritesPerTx = *numWritesPerTx
conf.txConf.numReadsPerTx = *numReadsPerTx
conf.batchConf.BatchSize = *batchSize
conf.dataConf.numKVs = *numKVs
conf.dataConf.kvSize = *kvSize
conf.dataConf.useJSON = *useJSON
return conf
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/mirrors/hyperledger-fabric.git
git@gitee.com:mirrors/hyperledger-fabric.git
mirrors
hyperledger-fabric
hyperledger-fabric
v1.1.0

搜索帮助