Add --timing flag
MODIFY
packages/@romejs/cli/cli.ts
packages/@romejs/cli/cli.ts
@@ -103,6 +103,9 @@ export default async function cli() {
collectMarkers: c.get('collectMarkers').asBoolean(
DEFAULT_CLIENT_REQUEST_FLAGS.collectMarkers,
),
+ timing: c.get('timing').asBoolean(
+ DEFAULT_CLIENT_REQUEST_FLAGS.timing,
+ ),
watch: c.get('watch').asBoolean(DEFAULT_CLIENT_REQUEST_FLAGS.watch),
fieri: c.get('fieri').asBoolean(DEFAULT_CLIENT_REQUEST_FLAGS.fieri),
focus: c.get('focus').asString(DEFAULT_CLIENT_REQUEST_FLAGS.focus),

MODIFY
packages/@romejs/core/common/types/client.ts
packages/@romejs/core/common/types/client.ts
@@ -21,6 +21,7 @@ export const DEFAULT_CLIENT_FLAGS: ClientFlags = {
export const DEFAULT_CLIENT_REQUEST_FLAGS: ClientRequestFlags = {
collectMarkers: false,
+ timing: false,
benchmark: false,
benchmarkIterations: 10,
@@ -36,6 +37,7 @@ export type ClientRequestFlags = DiagnosticsPrinterFlags & {
watch: boolean;
// Debugging
+ timing: boolean;
collectMarkers: boolean;
benchmark: boolean;
benchmarkIterations: number;

MODIFY
packages/@romejs/core/master/MasterRequest.ts
packages/@romejs/core/master/MasterRequest.ts
@@ -133,6 +133,7 @@ export default class MasterRequest {
this.client = opts.client;
this.id = requestIdCounter++;
this.markers = [];
+ this.start = Date.now();
this.normalizedCommandFlags = {
flags: {},
@@ -140,6 +141,7 @@ export default class MasterRequest {
};
}
+ start: number;
client: MasterClient;
query: MasterQueryRequest;
master: Master;
@@ -164,6 +166,13 @@ export default class MasterRequest {
teardown(
res: undefined | MasterQueryResponse,
): undefined | MasterQueryResponse {
+ // Output timing information
+ if (this.query.requestFlags.timing) {
+ const end = Date.now();
+ this.reporter.info(`Request took <duration emphasis>${String(end -
+ this.start)}</duration>`);
+ }
+
if (res !== undefined) {
// If the query asked for no data then strip all diagnostics and data values
if (this.query.noData) {

Add --timing flag