Skip to content

Commit

Permalink
chore: uncomment writer switch time calculations
Browse files Browse the repository at this point in the history
  • Loading branch information
karenc-bq committed Oct 23, 2024
1 parent 6bdbdca commit 8de1c7a
Showing 1 changed file with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ async function measurePerformance(config: any): Promise<Result> {
const elapsedSwitchToReaderTimeNanos: bigint[] = [];
const elapsedSwitchToWriterTimeNanos: bigint[] = [];

for (let i = 0; i < 1; i++) {
for (let i = 0; i < REPEAT_TIMES; i++) {
logger.info(`Test iteration ${i}`);
const client = DriverHelper.getClient(driver)(config);
try {
Expand All @@ -127,19 +127,19 @@ async function measurePerformance(config: any): Promise<Result> {
logger.info(`connect time ${connectTime}, execution time ${executionTime}, time1 ${time1}: ${time1 - connectTime - executionTime}`);
elapsedSwitchToReaderTimeNanos.push(time1 - connectTime - executionTime);

// // Calculate time required to switch to an existing writer connection.
// ConnectTimePlugin.resetConnectTime();
// ExecuteTimePlugin.resetExecuteTime();
//
// switchToWriterStartTime = getTimeInNanos();
// await client.setReadOnly(false);
//
// connectTime = ConnectTimePlugin.getTotalConnectTime();
// executionTime = ExecuteTimePlugin.getTotalExecuteTime();
// elapsedSwitchToWriterTimeNanos.push(getTimeInNanos() - switchToWriterStartTime - connectTime - executionTime);
// const time2 = getTimeInNanos() - switchToWriterStartTime;
// logger.info(`connect time ${connectTime}, execution time ${executionTime}, time2 ${time1}: ${time2 - connectTime - executionTime}`);
// elapsedSwitchToReaderTimeNanos.push(time2 - connectTime - executionTime);
// Calculate time required to switch to an existing writer connection.
ConnectTimePlugin.resetConnectTime();
ExecuteTimePlugin.resetExecuteTime();

switchToWriterStartTime = getTimeInNanos();
await client.setReadOnly(false);

connectTime = ConnectTimePlugin.getTotalConnectTime();
executionTime = ExecuteTimePlugin.getTotalExecuteTime();
elapsedSwitchToWriterTimeNanos.push(getTimeInNanos() - switchToWriterStartTime - connectTime - executionTime);
const time2 = getTimeInNanos() - switchToWriterStartTime;
logger.info(`connect time ${connectTime}, execution time ${executionTime}, time2 ${time1}: ${time2 - connectTime - executionTime}`);
elapsedSwitchToReaderTimeNanos.push(time2 - connectTime - executionTime);
} finally {
await client.end();
}
Expand All @@ -152,11 +152,11 @@ async function measurePerformance(config: any): Promise<Result> {
data.switchToReaderMax = max;
data.switchToReaderAvg = avg;

// [min, max, sum] = calculateStats(elapsedSwitchToWriterTimeNanos);
// avg = sum / BigInt(elapsedSwitchToWriterTimeNanos.length);
// data.switchToWriterMin = min;
// data.switchToWriterMax = max;
// data.switchToWriterAvg = avg;
[min, max, sum] = calculateStats(elapsedSwitchToWriterTimeNanos);
avg = sum / BigInt(elapsedSwitchToWriterTimeNanos.length);
data.switchToWriterMin = min;
data.switchToWriterMax = max;
data.switchToWriterAvg = avg;

return data;
}
Expand Down

0 comments on commit 8de1c7a

Please sign in to comment.