Skip to content

Commit 150c709

Browse files
committed
also print duration in the callaback execution
Signed-off-by: shirady <[email protected]>
1 parent ec27eb3 commit 150c709

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Diff for: src/sdk/namespace_fs.js

+11
Original file line numberDiff line numberDiff line change
@@ -1086,7 +1086,10 @@ class NamespaceFS {
10861086
const bytesRead = await file.read(fs_context, buffer, 0, read_size, pos);
10871087
if (!bytesRead) {
10881088
buffer_pool_cleanup = null;
1089+
const start_time = performance.now();
10891090
callback();
1091+
const end_time = performance.now();
1092+
dbg.log2(`get_buffer: Time taken to execute callback is ${end_time - start_time} ms.`);
10901093
break;
10911094
}
10921095
object_sdk.throw_if_aborted();
@@ -1111,15 +1114,22 @@ class NamespaceFS {
11111114

11121115
// wait for response buffer to drain before adding more data if needed -
11131116
// this occurs when the output network is slower than the input file
1117+
const start_time_drain_promise = performance.now();
11141118
if (drain_promise) {
1119+
dbg.log2('iniside condition: drain_promise');
11151120
await drain_promise;
11161121
drain_promise = null;
11171122
object_sdk.throw_if_aborted();
11181123
}
1124+
const end_time_drain_promise = performance.now();
1125+
dbg.log2(`drain_promise: Time taken to execute is ${end_time_drain_promise - start_time_drain_promise} ms.`);
11191126

11201127
// write the data out to response
11211128
buffer_pool_cleanup = null; // cleanup is now in the socket responsibility
1129+
const start_time_write = performance.now();
11221130
const write_ok = res.write(data, null, callback);
1131+
const end_time_write = performance.now();
1132+
dbg.log2(`write to socket: Time taken to execute is ${end_time_write - start_time_write} ms.`);
11231133
if (!write_ok) {
11241134
drain_promise = stream_utils.wait_drain(res, { signal: object_sdk.abort_controller.signal });
11251135
drain_promise.catch(() => undefined); // this avoids UnhandledPromiseRejection
@@ -1132,6 +1142,7 @@ class NamespaceFS {
11321142

11331143
// wait for the last drain if pending.
11341144
if (drain_promise) {
1145+
dbg.log2('iniside condition2 (last drain): drain_promise');
11351146
await drain_promise;
11361147
drain_promise = null;
11371148
object_sdk.throw_if_aborted();

0 commit comments

Comments
 (0)