캘리퍼 벤치마크 제너레이터는 배포된 스마트 컨트랙트에서 벤치마크를 수행하기 위한 구성 및 콜백 파일을 생성하기 위한 요먼 제너레이터(Yeoman generator)이다. 이 페이지는 제너레이터 설치 및 사용을 설명한다.
제너레이터 설치와 사용을 위해서는 설치된 요먼이 먼저 필요하다. 아래 커맨드를 사용하자:
npm install -g yo
요먼이 설치되면 아래 커맨드로 제너레이터를 설치한다:
npm install -g @hyperledger/generator-caliper
제너레이터 사용을 위해 아래 커맨드를 실행한다.
yo caliper
성공하면 제너레이터를 선택하라는 아래와 같은 결과를 얻을 수 있다. 캘리퍼 벤치마크 제너레이터 구동을 위해 Benchmark를 선택하자.
Welcome to the Hyperledger Caliper generator!
? Which generator would you like to run? (Use arrow keys)
❯ Benchmark
대신 yo caliper:benchmark
를 사용해 벤치마크 제너레이터를 구동할 수 있다.
이제 워크스페이스 이름을 지정하라는 아래와 같은 결과를 얻는다:
Welcome to the Hyperledger Caliper benchmark generator!
Let's start off by creating a workspace folder!
? What would you like to call your workspace? myWorkspace
벤치마크 제너레이터는 처음으로 콜백 파일 생성으로 사용자를 데려가고, 아래를 결정해야 한다:
마지막에, 아래와 같은 결과를 얻을 수 있다:
Now for the callback file...
? What is the name of your smart contract? fabcar
? What is the version of your smart contract? 0.0.1
? Which smart contract function would you like to perform the benchmark on? changeCarOwner
? What are the arguments of your smart contract function? (e.g. ["arg1", "arg2"]) ["CAR001", "Tom"]
다음으로 아래를 입력해 구성 파일을 생성할 수 있다:
참고
유효하지 않은 워커 수가 입력되면 기본 값이 사용된다.
opts
를 사용한다.? Which rate controller would you like to use? (Use arrow keys)
❯ Fixed Rate
Fixed Backlog
Linear Rate
Fixed Feedback Rate
? How would you like to measure the length of the round? (Use arrow keys)
❯ Transaction Duration
Transaction Number
txNumber
또는 txDuration
에 대한 값.참고
유효하지 않은 값을 입력하면 기본값이 사용된다.
마지막에는 아래와 비슷한 결과물을 얻게 된다:
Now for the benchmark configuration file...
? What would you like to name your benchmark? Fabcar benchmark
? What description would you like to provide for your benchamrk? Benchmark for performance testing fabcar contract modules
? How many workers would you like to have? 5
? What label (hint for test) would you like to provide for your benchmark? Round for changing car owner
? Which rate controller would you like to use? Fixed Rate
? How would you like to measure the length of the round? Transaction Number
? How many transactions would you like to have in this round? 60
성공적으로 생성하면 아래를 볼 수 있다:
Generating benchmarking files...
create myBenchmark/benchmarks/callbacks/changeCarOwner.js
create myBenchmark/benchmarks/config.yaml
Finished generating benchmarking files
아래 커맨드라인 옵션을 이용해 비대화식으로(non-interactively) 제너레이터를 구동할 수 있다:
옵션 | 기본값 | 설명 |
---|---|---|
--workspace | 모든 생성된 벤치마크 파일을 둘 워크스페이스 | |
--contractId | 스마트컨트랙트 이름 | |
--version | 스마트컨트랙트 버전 | |
--contractFunction | 스마트 컨트랙트 함수 | |
--contractArguments | [] | 스마트 컨트랙트 함수의 arguments. 반드시 배열 형태여야 한다. |
--benchmarkName | 벤치마크 이름 | |
--benchmarkDescription | 벤치마크 설명 | |
--workers | 5 | 워커 수 |
--label | 라운드를 위한 라벨 | |
--rateController | 레이트 컨트롤러 | |
--txType | 라운드 길이 측정 방법. "txDuration" 또는 "txNumber". | |
--txDuration | 50 | txType이 txDuration이라면 트랜잭션 지속기간 |
--txNumber | 50 | txType이 txNumber라면 트랜잭션 수 |
아래는 비대화적으로 커맨드라인을 사용해 제너레이터를 구동하는 예시이다:
yo caliper:benchmark -- --workspace 'myWorkspace' --contractId 'fabcar' --version '0.0.1' --contractFunction 'changeCarOwner' --contractArguments '["CAR001", "Tom"]' --benchmarkName 'Fabcar benchmark' --benchmarkDescription 'Benchmark for performance testing fabcar contract modules' --workers 5 --label 'Round for changing car owner' --rateController 'fixed-rate' --txType 'txDuration' --txDuration 50
참고
제너레이터를 비대화적으로 사용하려면 위 모든 옵션이 필수이다.
생성된 파일은 처음 제너레이터에서 이름붙인 워크스페이스에 위치한다. 아래와 비슷한 디렉토리 구조를 가져야 한다:
.myWorkspace
└── benchmarks
│ callbacks
│ └── changeCarOwner.js
└─ config.yaml
현재, 제너레이터는 invokerIdentity
나 contractArguments
를 콜백 파일에 대한 입력으로 제공하지 않는다. 이것이 필요한 경우 콜백 파일의 run
함수에서 이것들을 제공해야 한다.
제너레이터는 한 스마트 컨트랙트 함수에 대한 단일 콜백 파일만을 생성한다. 만약 다른 스마트 컨트랙트 함수를 테스트하고싶다면 더 많은 콜백 파일을 콜백 디렉토리에 생성해야 한다. 또한 이 추가 콜백들을 고려하도록 벤치마크 구성 파일을 업데이트해야 한다.
참고
벤치마크 제너레이터는 벤치마크 구성 파일과 콜백 파일만을 생성할 뿐이다. 여전히 네트워크 구성 파일을 벤치마크 수행을 위해 직접 제공해주어야 한다.
The Caliper codebase is released under the Apache 2.0 license. Any documentation developed by the Caliper Project is licensed under the Creative Commons Attribution 4.0 International License. You may obtain a copy of the license, titled CC-BY-4.0, at http://creativecommons.org/licenses/by/4.0/.