当前位置: 首页 > news >正文

Hyperledger caliper 性能测试

前言:Hyperledger  caliper 的本质是使用node对被测试网络进行压力测试,因此需要nodejs。本次使用 Hyperledger caliper 0.5 对 fabric 1.4.6进行压测

准备条件:nodejs 16 (略 linux下 解压+环境变量即可)

# 创建工作目录
mkdir /opt/fabric/caliper
# 进入工作目录
cd /opt/fabric/caliper
# 安装 caliper CLI, (如果慢 可以使用代理  sudo npm config set https-proxy http://172.16.10.34:7890)
npm install --only=prod @hyperledger/caliper-cli@0.5.0 
#绑定fabri
npx caliper bind --caliper-bind-sut fabric:1.4

配置文件(放在工作空间中:/root/fabric/caliper)

network-config.yaml (配置要测试的网络和组织信息)

name: Caliper Benchmarks
version: "2.0.0"caliper:blockchain: fabricchannels:# channelName of mychannel matches the name of the channel created by test network- channelName: channel1# the chaincodeIDs of all the fabric chaincodes in caliper-benchmarkscontracts:- id: ccmaporganizations:- mspid: Org1MSP# Identities come from cryptogen created material for test-networkidentities:certificates:- name: 'Admin'clientPrivateKey:path: '/opt/fabric/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/keystore/5ca88db427a2026c0c16fbba1bd17d9e596683f1fa7c8a9b412d88604b63e66d_sk'clientSignedCert:path: '/opt/fabric/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/signcerts/Admin@org1.example.com-cert.pem'connectionProfile:path: 'connection-org1.yaml'discover: true

connection-org1.yaml (配置组织的连接信息)

---
name: first-network-org1
version: 1.0.0
client:organization: Org1connection:timeout:peer:endorser: '300'
organizations:Org1:mspid: Org1MSPpeers:- peer0.org1.example.com
peers:peer0.org1.example.com:url: grpcs://localhost:7051tlsCACerts:path: /opt/fabric/crypto-config/peerOrganizations/org1.example.com/tlsca/tlsca.org1.example.com-cert.pemgrpcOptions:ssl-target-name-override: peer0.org1.example.com

benchmark-config.yaml (配置压力测试的参数)

test:workers:number: 5rounds:- label: Query map.txDuration: 30rateControl:type: fixed-loadopts:transactionLoad: 1000workload:module: workload/query.jsarguments:assets: 2

query.js (在子目录下,绝对路径为:/root/fabric/caliperworkload/query.js) 根据业务编写查询方法或插入方法

'use strict';const { WorkloadModuleBase } = require('@hyperledger/caliper-core');class QueryAssetWorkload extends WorkloadModuleBase {constructor() {super();}async initializeWorkloadModule(workerIndex, totalWorkers, roundIndex, roundArguments, sutAdapter, sutContext) {await super.initializeWorkloadModule(workerIndex, totalWorkers, roundIndex, roundArguments, sutAdapter, sutContext);}async submitTransaction() {await this.sutAdapter.sendRequests({contractId: 'ccmap',  // 你的链码名称contractFunction: 'query', // 查询方法contractArguments: ["a"],readOnly: true});}
} module.exports.createWorkloadModule = () => new QueryAssetWorkload();

执行

 npx caliper launch manager   --caliper-workspace .   --caliper-benchconfig /opt/fabric/caliper/benchmark-config.yaml   --caliper-networkconfig /opt/fabric/caliper/network-config.yaml  --caliper-flow-only-test --caliper-fabric-gateway-enabled

测试效果如下

http://www.lryc.cn/news/535525.html

相关文章:

  • Record-Mode 备案免关站插件,让 WordPress 备案不影响 SEO 和收录
  • 【Java 面试 八股文】Redis篇
  • 介绍几款免费的显示器辅助工具!
  • django配置跨域
  • web前端第三次作业
  • 【Pandas】pandas Series align
  • DeepSeek-V3网络模型架构图解
  • Linux系统管理小课堂
  • 明远智睿核心板在智能家居与工业网关中的应用实践
  • Windows 系统 GDAL库 配置到 Qt 上
  • 部署onlyoffice后,php版的callback及小魔改(logo和关于)
  • 《qt open3d网格拉普拉斯平滑》
  • 【愚公系列】《Python网络爬虫从入门到精通》004-请求模块urllib3
  • 网络安全技术复习总结
  • 初阶c语言(while循环二分法)
  • 如何使用Java语言在Idea和Android中分别建立服务端和客户端实现局域网聊天
  • Java_多线程
  • uniapp开发h5部署到服务器
  • 如何在个人电脑本地化部署Deepseek-R1大模型
  • Java中关于JSON的基本使用
  • 简化的动态稀疏视觉Transformer的PyTorch代码
  • PADS多层板减少层数
  • 你需要提供管理员权限才能删除此文件夹解决方法
  • 螺旋折线(蓝桥杯18G)
  • 常见的数据仓库有哪些?
  • 数据科学之数据管理|NumPy数据管
  • LSTM 学习笔记 之pytorch调包每个参数的解释
  • ASUS/华硕飞行堡垒9 FX506H FX706H 原厂Win10系统 工厂文件 带ASUS Recovery恢复
  • Unity使用iTextSharp导出PDF-04图形
  • JDBC如何连接数据库