Skip to content

Commit

Permalink
make serialize wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
AGawrys committed Nov 3, 2023
1 parent 75527f4 commit dbd3d13
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions packages/dev/query/src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,10 @@ export function run(input: string[]) {
'Deserialize (ms)',
'Serialize (ms)',
]);
let serialized: Map<string, number> = getSerializeTimes();
let serialized: Map<string, number> = new Map();
serialized.set('RequestGraph', timeSerialize(requestTracker));
serialized.set('bundle_graph_request', timeSerialize(bundleGraph));
serialized.set('asset_graph_request', timeSerialize(assetGraph));
for (let [k, v] of nullthrows(cacheInfo).entries()) {
let s = serialized.get(k);
invariant(s != null);
Expand All @@ -628,22 +631,12 @@ export function run(input: string[]) {
]);
_printStatsTable('Cache Info', table);
}
function getSerializeTimes(): Map<string, number> {
let serializeTime = new Map<string, number>();
let requestgraph_st = Date.now();
serialize(requestTracker);
requestgraph_st = Date.now() - requestgraph_st;
serializeTime.set('RequestGraph', requestgraph_st);
let bundlegraph_st = Date.now();
serialize(bundleGraph);
bundlegraph_st = Date.now() - bundlegraph_st;
serializeTime.set('bundle_graph_request', bundlegraph_st);
let assetgraph_st = Date.now();
serialize(assetGraph);
assetgraph_st = Date.now() - assetgraph_st;
serializeTime.set('asset_graph_request', assetgraph_st);

return serializeTime;

function timeSerialize(graph) {
let date = Date.now();
serialize(graph);
date = Date.now() - date;
return date;
}
function _printStatsTable(header, data) {
const config = {
Expand Down

0 comments on commit dbd3d13

Please sign in to comment.