diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2018-10-17 20:30:23 +0200 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2018-10-18 05:08:49 -0400 |
commit | 3a226f166fef38829810fb8813b46dee73c83005 (patch) | |
tree | 9b4a3fc598e96f544a59a1dc8eae796713bf17ac /src | |
parent | fd2bb015c721c2db447272b4e9cd47fec353c6e1 (diff) |
add test case for metrics
Diffstat (limited to 'src')
-rw-r--r-- | src/isolate.rs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/isolate.rs b/src/isolate.rs index 4d6f7cdfc..340b1db89 100644 --- a/src/isolate.rs +++ b/src/isolate.rs @@ -171,6 +171,8 @@ impl Isolate { } pub fn respond(&mut self, req_id: i32, buf: Buf) { + self.state.metrics_op_completed(buf.len() as u64); + // TODO(zero-copy) Use Buf::leak(buf) to leak the heap allocated buf. And // don't do the memcpy in ImportBuf() (in libdeno/binding.cc) unsafe { @@ -188,9 +190,7 @@ impl Isolate { // completing. self.ntasks_decrement(); // Call into JS with the buf. - let buf_size = buf.len() as u64; self.respond(req_id, buf); - self.state.metrics_op_completed(buf_size) } fn timeout(&mut self) { @@ -305,10 +305,13 @@ extern "C" fn pre_dispatch( // Execute op synchronously. let buf = tokio_util::block_on(op).unwrap(); let buf_size = buf.len(); + if buf_size != 0 { // Set the synchronous response, the value returned from isolate.send(). isolate.respond(req_id, buf); - isolate.state.metrics_op_completed(buf_size as u64); + } else { + // FIXME + isolate.state.metrics_op_completed(buf.len() as u64); } } else { // Execute op asynchronously. |