Benchmark Generator

개요


캘리퍼 벤치마크 제너레이터는 배포된 스마트 컨트랙트에서 벤치마크를 수행하기 위한 구성 및 콜백 파일을 생성하기 위한 요먼 제너레이터(Yeoman generator)이다. 이 페이지는 제너레이터 설치 및 사용을 설명한다.

설치


제너레이터 설치와 사용을 위해서는 설치된 요먼이 먼저 필요하다. 아래 커맨드를 사용하자:

npm install -g yo

요먼이 설치되면 아래 커맨드로 제너레이터를 설치한다:

npm install -g @hyperledger/generator-caliper

Generator 사용


제너레이터 사용을 위해 아래 커맨드를 실행한다.

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

콜백 프롬프트


벤치마크 제너레이터는 처음으로 콜백 파일 생성으로 사용자를 데려가고, 아래를 결정해야 한다:

  • 스마트 컨트랙트의 이름
  • 스마트 컨트랙트 버전
  • 스마트 컨트랙트 함수
  • 스마트 컨트랙트 함수의 argument 변수들. 반드시 배열 형태로 입력되어야 한다.

마지막에, 아래와 같은 결과를 얻을 수 있다:

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
  • 라운드 길이를 측정하기 위한 방법. 라운드 길이를 초 단위로 정의하는 transaction duration 또는 라운드에서 생성되는 트랜잭션 수로 라운드 길이를 정의하는 transaction number를 선택할 수 있다.
? 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벤치마크 설명
--workers5워커 수
--label라운드를 위한 라벨
--rateController레이트 컨트롤러
--txType라운드 길이 측정 방법. "txDuration" 또는 "txNumber".
--txDuration50txType이 txDuration이라면 트랜잭션 지속기간
--txNumber50txType이 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

현재, 제너레이터는 invokerIdentitycontractArguments를 콜백 파일에 대한 입력으로 제공하지 않는다. 이것이 필요한 경우 콜백 파일의 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/.

0개의 댓글

Powered by GraphCDN, the GraphQL CDN