Skip to content

Commit

Permalink
fix: move performance to test utils (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
bgiori authored Sep 1, 2022
1 parent 78822a0 commit 2608b6b
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 28 deletions.
4 changes: 0 additions & 4 deletions packages/node/src/remote/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
import { HttpClient } from '../types/transport';
import { ExperimentUser } from '../types/user';
import { Variant, Variants } from '../types/variant';
import { performance } from '../util/performance';
import { sleep } from '../util/time';

/**
Expand Down Expand Up @@ -75,7 +74,6 @@ export class RemoteEvaluationClient {
user: ExperimentUser,
timeoutMillis: number,
): Promise<Variants> {
const start = performance.now();
const userContext = this.addContext(user || {});
const endpoint = `${this.config.serverUrl}/sdk/vardata`;
const headers = {
Expand All @@ -101,8 +99,6 @@ export class RemoteEvaluationClient {
`fetch - received error response: ${response.status}: ${response.body}`,
);
}
const elapsed = (performance.now() - start).toFixed(3);
this.debug(`[Experiment] Fetch complete in ${elapsed} ms`);
const json = JSON.parse(response.body);
const variants = this.parseJsonVariants(json);
this.debug('[Experiment] Fetched variants: ', variants);
Expand Down
26 changes: 2 additions & 24 deletions packages/node/test/local/benchmark.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Experiment } from 'src/factory';
import { ExperimentUser } from 'src/types/user';
import { measure } from 'src/util/performance';
// import * as fs from "fs";

import { measure } from './util/performance';

const apiKey = 'server-5G5HQL3jUIPXWaJBTgAvDFHy277srxSg';

Expand Down Expand Up @@ -76,28 +76,6 @@ test('ExperimentClient.evaluate benchmark, 1000 flags < 1000ms', async () => {
expect(total).toBeLessThan(1000);
});

// Data generation for charts

// test('data - evaluation duration by iteration', async () => {
// let data = '';
// const iterations = 10000;
// for (let i = 0; i < iterations; i++) {
// const user = randomExperimentUser();
// const flag = randomBenchmarkFlag();
// const duration = await measure(async () => {
// await client.evaluate(user, [flag]);
// });
// data += `${duration.toFixed(3)},`;
// }
// // eslint-disable-next-line no-console
// data = data.replace(/.$/, '\n');
// fs.writeFileSync(
// `/Users/brian.giori/dev/charts/data/eval-dur-iteration-${iterations}.csv`,
// data,
// { flag: 'a+' },
// );
// });

// Utilities

const randomBenchmarkFlag = (): string => {
Expand Down
File renamed without changes.

0 comments on commit 2608b6b

Please sign in to comment.