@hyperledger/caliper-core
Advanced tools
Comparing version 0.3.1-unstable-20200409140324 to 0.3.1-unstable-20200409141009
@@ -94,3 +94,4 @@ /* | ||
Address: 'caliper-worker-communication-address', | ||
} | ||
}, | ||
MaxTxPromises: 'caliper-worker-maxtxpromises' | ||
}, | ||
@@ -97,0 +98,0 @@ Flow: { |
@@ -19,2 +19,3 @@ /* | ||
const CaliperUtils = require('../../common/utils/caliper-utils.js'); | ||
const CircularArray = require('../../common/utils/circular-array'); | ||
const bc = require('../../common/core/blockchain.js'); | ||
@@ -41,2 +42,4 @@ const RateControl = require('../rate-control/rateControl.js'); | ||
this.context = undefined; | ||
this.txUpdateTime = Config.get(Config.keys.TxUpdateTime, 5000); | ||
this.maxTxPromises = Config.get(Config.keys.Worker.MaxTxPromises, 100); | ||
@@ -245,4 +248,4 @@ // Internal stats | ||
let promises = []; | ||
while(this.txNum < number) { | ||
const circularArray = new CircularArray(this.maxTxPromises); | ||
while (this.txNum < number) { | ||
// If this function calls cb.run() too quickly, micro task queue will be filled with unexecuted promises, | ||
@@ -252,3 +255,3 @@ // and I/O task(s) will get no chance to be execute and fall into starvation, for more detail info please visit: | ||
await this.setImmediatePromise(() => { | ||
promises.push(cb.run().then((result) => { | ||
circularArray.add(cb.run().then((result) => { | ||
this.addResult(result); | ||
@@ -261,3 +264,3 @@ return Promise.resolve(); | ||
await Promise.all(promises); | ||
await Promise.all(circularArray); | ||
this.endTime = Date.now(); | ||
@@ -277,3 +280,4 @@ } | ||
let promises = []; | ||
// Use a circular array of Promises so that the Promise.all() call does not exceed the maximum permissable Array size | ||
const circularArray = new CircularArray(this.maxTxPromises); | ||
while ((Date.now() - this.startTime)/1000 < duration) { | ||
@@ -284,3 +288,3 @@ // If this function calls cb.run() too quickly, micro task queue will be filled with unexecuted promises, | ||
await this.setImmediatePromise(() => { | ||
promises.push(cb.run().then((result) => { | ||
circularArray.add(cb.run().then((result) => { | ||
this.addResult(result); | ||
@@ -293,3 +297,3 @@ return Promise.resolve(); | ||
await Promise.all(promises); | ||
await Promise.all(circularArray); | ||
this.endTime = Date.now(); | ||
@@ -331,3 +335,2 @@ } | ||
this.txUpdateTime = Config.get(Config.keys.TxUpdateTime, 5000); | ||
const self = this; | ||
@@ -386,3 +389,2 @@ let initUpdateInter = setInterval( () => { self.initUpdate(); } , self.txUpdateTime); | ||
this.txUpdateTime = Config.get(Config.keys.TxUpdateTime, 1000); | ||
Logger.info('txUpdateTime: ' + this.txUpdateTime); | ||
@@ -389,0 +391,0 @@ const self = this; |
{ | ||
"name": "@hyperledger/caliper-core", | ||
"description": "Core Hyperledger Caliper module, used for running performance benchmarks that interact with blockchain technologies", | ||
"version": "0.3.1-unstable-20200409140324", | ||
"version": "0.3.1-unstable-20200409141009", | ||
"repository": { | ||
@@ -6,0 +6,0 @@ "type": "git", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
466117
68
10416