Skip to content

Commit

Permalink
Merge branch 'pr-gh-page' of https://github.com/psankhe28/caliper int…
Browse files Browse the repository at this point in the history
…o pr-gh-page
  • Loading branch information
psankhe28 committed Nov 16, 2024
2 parents be5c309 + 6281eec commit e165fa4
Show file tree
Hide file tree
Showing 22 changed files with 999 additions and 86 deletions.
24 changes: 24 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "Caliper Development",
"image": "mcr.microsoft.com/vscode/devcontainers/python:3.11",
"features": {
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {},
"ghcr.io/devcontainers/features/node:1": {
"version": "lts"
}
},
"customizations": {
"vscode": {
"settings": {
"terminal.integrated.shell.linux": "/bin/bash",
"python.defaultInterpreterPath": "/usr/local/bin/python"
},
"extensions": [
"esbenp.prettier-vscode",
]
}
},
"postCreateCommand": "cd docs && pip install -r pip-requirements.txt && mkdocs build",
"remoteUser": "vscode",
"forwardPorts": [8000]
}
2 changes: 1 addition & 1 deletion .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
fail-fast: false
matrix:
adaptor: ${{ fromJSON(needs.changes.outputs.adaptor) }}
node-version: [18.x, 20.x]
node-version: [18.x, 20.x, 22.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x]
node-version: [18.x, 20.x, 22.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ This guideline intends to make contribtuions to Caliper easier by:

If you have further suggestions about improving the guideline, then you can follow the presented workflow to make your contribution.

Jump to [Contributing documentation](https://hyperledger.github.io/caliper/v0.6.0/contributing) to get started on your journey.
Jump to [Contributing documentation](https://hyperledger-caliper.github.io/caliper/v0.6.0/contributing) to get started on your journey.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ Currently supported performance indicators:

See the [PSWG white paper](https://www.hyperledger.org/learn/publications/blockchain-performance-metrics) to find out the definitions and corresponding measurement methods.

For more information on using Caliper, please consult the [documentation site](https://hyperledger.github.io/caliper/)
For more information on using Caliper, please consult the [documentation site](https://hyperledger-caliper.github.io/caliper/)

## Configuration and usage
See the [related documentation page](https://hyperledger.github.io/caliper/).
See the [related documentation page](https://hyperledger-caliper.github.io/caliper/).

## How to contact us

Expand Down
10 changes: 5 additions & 5 deletions docs/source/getting-started/installing-caliper.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Examples:
caliper launch manager
caliper launch worker

For more information on Hyperledger Caliper: https://hyperledger.github.io/caliper/
For more information on Hyperledger Caliper: https://hyperledger-caliper.github.io/caliper/
```
You can also request the help page of a specific command, as demonstrated by the next subsections.

Expand Down Expand Up @@ -240,7 +240,7 @@ Let’s see the three types of version numbers you will encounter:

### Pre-requisites

- Node.js v18 LTS or v20 LTS or later LTS version is required to install the Caliper CLI from NPM:
- Node.js v18 LTS, v20 LTS or v22 LTS version is required to install the Caliper CLI from NPM:
- Docker version 20.10.11 or later is required for use with the Caliper docker image

The following tools may be required depending on which SUT and version you bind to
Expand Down Expand Up @@ -317,7 +317,7 @@ Depending on your NPM settings, your user might need write access to directories

## Using the Docker image

Caliper is published as the [hyperledger/caliper](https://hub.docker.com/r/hyperledger/caliper) Docker image, providing a single point of usage for every supported adapter.
Caliper is published as the [hyperledger/caliper](https://hub.docker.com/r/hyperledger/caliper) Docker image, providing a single point of usage for every supported adapter.

The important properties of the image are the following:

Expand All @@ -326,7 +326,7 @@ The important properties of the image are the following:
* The environment variable `CALIPER_WORKSPACE` is set to the `/hyperledger/caliper/workspace` directory
* The entry point is the **globally** installed `caliper` binary
* The environment variable `CALIPER_BIND_ARGS` is set to `-g`, so the binding step also occurs globally.
* The default command is set to `--version`. This must be overridden when using the image.
* The default command is set to `--version`. This must be overridden when using the image.

This has the following implications:

Expand Down Expand Up @@ -390,4 +390,4 @@ docker-compose up

## License

The Caliper codebase is released under the [Apache 2.0 license](../getting-started/license.md). 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/](http://creativecommons.org/licenses/by/4.0/).
The Caliper codebase is released under the [Apache 2.0 license](../getting-started/license.md). 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/](http://creativecommons.org/licenses/by/4.0/).
4 changes: 2 additions & 2 deletions docs/source/tutorial/fabric.md
Original file line number Diff line number Diff line change
Expand Up @@ -511,8 +511,8 @@ The resulting report will detail the following items for each benchmark round:
- Latency (max/min/avg) - statistics relating to the time taken in seconds between issuing a transaction and receiving a response
- Throughput - the average number of transactions processed per second
You have successfully benchmarked a smart contract. You can repeat the test varying the benchmark parameters, as well as adding resource monitors. For the full set of options, please refer to the [Caliper Documentation](https://hyperledger.github.io/caliper/)
You have successfully benchmarked a smart contract. You can repeat the test varying the benchmark parameters, as well as adding resource monitors. For the full set of options, please refer to the [Caliper Documentation](https://hyperledger-caliper.github.io/caliper/)
## License
The Caliper codebase is released under the [Apache 2.0 license](../getting-started/license.md). 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/](http://creativecommons.org/licenses/by/4.0/).
The Caliper codebase is released under the [Apache 2.0 license](../getting-started/license.md). 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/](http://creativecommons.org/licenses/by/4.0/).
Original file line number Diff line number Diff line change
Expand Up @@ -129,17 +129,17 @@
},
"projectconfig": {
"title": "Project Configuration",
"description": "projectconfig:If you have a group of settings that are always overridden in your Caliper benchmark project, then it is recommended to define them as a project-level configuration file. This file will usually consist of a subset of settings defined in the default configuration file (and probably your custom settings associated with your custom user module). More information: https://hyperledger.github.io/caliper/v0.5.0/runtime-config/#project-level",
"description": "projectconfig:If you have a group of settings that are always overridden in your Caliper benchmark project, then it is recommended to define them as a project-level configuration file. This file will usually consist of a subset of settings defined in the default configuration file (and probably your custom settings associated with your custom user module). More information: https://hyperledger-caliper.github.io/caliper/v0.6.0/runtime-config/#project-level",
"type": "null"
},
"userconfig": {
"title": "User Configuration",
"description": "userconfig: If you find yourself overriding the same settings for multiple Caliper benchmark projects, then it is recommended to extract the common settings into a user-level configuration file. More information: https://hyperledger.github.io/caliper/v0.5.0/runtime-config/#user-level",
"description": "userconfig: If you find yourself overriding the same settings for multiple Caliper benchmark projects, then it is recommended to extract the common settings into a user-level configuration file. More information: https://hyperledger-caliper.github.io/caliper/v0.6.0/runtime-config/#user-level",
"type": "null"
},
"machineconfig": {
"title": "Machine Configuration",
"description": "machineconfig: If multiple users use the same workstation and want to share common settings across Caliper projects and users, then a machine-level configuration file can be included into the hierarchy by specifying its path through the caliper-machineconfig settings key using one of the higher priority locations above. More information: https://hyperledger.github.io/caliper/v0.5.0/runtime-config/#machine-level",
"description": "machineconfig: If multiple users use the same workstation and want to share common settings across Caliper projects and users, then a machine-level configuration file can be included into the hierarchy by specifying its path through the caliper-machineconfig settings key using one of the higher priority locations above. More information: https://hyperledger-caliper.github.io/caliper/v0.6.0/runtime-config/#machine-level",
"type": "null"
},
"benchconfig": {
Expand Down Expand Up @@ -585,4 +585,4 @@
"title": "Configuration Helper"
}
}
}
}
2 changes: 1 addition & 1 deletion packages/caliper-cli/caliper.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ let results = yargs
.demandCommand(1, 1, 'Please specify a command to continue')
.example('caliper bind\ncaliper unbind\ncaliper launch manager\ncaliper launch worker')
.wrap(null)
.epilogue('For more information on Hyperledger Caliper: https://hyperledger.github.io/caliper/')
.epilogue('For more information on Hyperledger Caliper: https://hyperledger-caliper.github.io/caliper/')
.alias('version', 'v')
.alias('help', 'h')
.version(version)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
<body style="font-family: IBM Plex Sans; font-weight: 200;">
<main>
<div class="left-column">
<img src="https://hyperledger.github.io/caliper/assets/img/hyperledger_caliper_logo_color.png" style="width:95%;" alt="">
<img src="https://hyperledger-caliper.github.io/caliper/assets/img/hyperledger_caliper_logo_color.png" style="width:95%;" alt="">
<ul>
<h3>&nbspBasic information</h3>
{{#summary.meta}}
Expand Down
15 changes: 8 additions & 7 deletions packages/caliper-core/lib/worker/caliper-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,10 @@ class CaliperWorker {
* @param {Object} rateController rate controller object
* @async
*/
async runFixedNumber(workloadModule, number, rateController) {
async _runFixedNumber(workloadModule, number, rateController) {
const stats = this.internalTxObserver.getCurrentStatistics();
let error = undefined;

while (stats.getTotalSubmittedTx() < number && !error) {
await rateController.applyRateControl();

Expand All @@ -107,18 +108,19 @@ class CaliperWorker {
await CaliperWorker._waitForTxsToFinish(stats);
}


/**
* Perform test with specified test duration
* @param {object} workloadModule The user test module.
* @param {Object} duration duration to run for
* @param {Object} rateController rate controller object
* @async
*/
async runDuration(workloadModule, duration, rateController) {
async _runDuration(workloadModule, duration, rateController) {
const stats = this.internalTxObserver.getCurrentStatistics();
let startTime = stats.getRoundStartTime();
let error = undefined;
while ((Date.now() - startTime) < (duration * 1000) && !error) {
while ((Date.now() - startTime) < (duration * 1000) && !error) {
await rateController.applyRateControl();

// If this function calls this.workloadModule.submitTransaction() too quickly, micro task queue will be filled with unexecuted promises,
Expand Down Expand Up @@ -161,7 +163,7 @@ class CaliperWorker {
await this.workloadModule.initializeWorkloadModule(this.workerIndex, prepareTestMessage.getWorkersNumber(), roundIndex, prepareTestMessage.getWorkloadSpec().arguments, this.connector, context);
await CaliperUtils.sleep(this.txUpdateTime);
} catch (err) {
Logger.info(`Worker [${this.workerIndex}] encountered an error during prepare test phase for round ${roundIndex}: ${(err.stack ? err.stack : err)}`);
Logger.warn(`Worker [${this.workerIndex}] encountered an error during prepare test phase for round ${roundIndex}: ${(err.stack ? err.stack : err)}`);
throw err;
} finally {
await this.connector.releaseContext(context);
Expand Down Expand Up @@ -201,12 +203,11 @@ class CaliperWorker {

if (testMessage.getRoundDuration()) {
const duration = testMessage.getRoundDuration(); // duration in seconds
await this.runDuration(this.workloadModule, duration, rateController);
await this._runDuration(this.workloadModule, duration, rateController);
} else {
const number = testMessage.getNumberOfTxs();
await this.runFixedNumber(this.workloadModule, number, rateController);
await this._runFixedNumber(this.workloadModule, number, rateController);
}

Logger.debug(`Worker #${this.workerIndex} finished round #${roundIndex}`, this.internalTxObserver.getCurrentStatistics().getCumulativeTxStatistics());
return this.internalTxObserver.getCurrentStatistics();
} catch (err) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ class FixedFeedbackRateController extends RateInterface {
if (this.generalSleepTime === 0 || currentSubmitted < this.unfinishedPerWorker) {
return;
}

if (this.stats.getTotalFinishedTx() === 0) {
return;
}
Expand All @@ -74,7 +73,12 @@ class FixedFeedbackRateController extends RateInterface {
return;
}

let diff = (this.generalSleepTime * currentSubmitted - ((Date.now() - this.totalSleepTime) - this.stats.getRoundStartTime()));
const expectedTime = this.generalSleepTime * currentSubmitted;
const actualElapsedTime = (Date.now() - this.totalSleepTime) - this.stats.getRoundStartTime();
const diff = expectedTime - actualElapsedTime;

// If we're ahead by more than 5ms, adjust by sleeping for the difference
// 5ms is used to avoid negligible adjustments that could cause unnecessary delays
if (diff > 5) {
await util.sleep(diff);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,12 @@ class LoggingTxObserver extends TxObserverInterface{
* @param {TxStatus | TxStatus[]} results The result information of the finished TXs. Can be a collection of results for a batch of TXs.
*/
txFinished(results) {
// TODO: appending metadata should be done by the dispatch
if (Array.isArray(results)) {
for (let result of results) {
// add extra metadata
result.workerIndex = this.workerIndex;
result.roundIndex = this.roundIndex;

// TODO: use fast-json-stringify
this.logFunction(JSON.stringify(result));
}
} else {
// add extra metadata
results.workerIndex = this.workerIndex;
results.roundIndex = this.roundIndex;

// TODO: use fast-json-stringify
this.logFunction(JSON.stringify(results));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,33 +102,20 @@ class TxObserverDispatch extends TxObserverInterface {
return;
}

if (Array.isArray(results)) {
for (let result of results) {
result.workerIndex = this.workerIndex;
result.roundIndex = this.currentRound;
}
}else {
results.workerIndex = this.workerIndex;
results.roundIndex = this.currentRound;
}

for (let observer of this.txObservers) {
observer.txFinished(results);
}
}
}

module.exports = TxObserverDispatch;























Loading

0 comments on commit e165fa4

Please sign in to comment.