summaryrefslogtreecommitdiff
path: root/dispatch.go
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2018-05-25 17:14:56 -0400
committerRyan Dahl <ry@tinyclouds.org>2018-05-25 17:14:56 -0400
commita1c0862047c47f02fb07bcf01f35e3cf5c2266d3 (patch)
tree32731f979e639120ffd0640a71789f359560848f /dispatch.go
parent59534fb9e357b08df47a6923f036090e82017396 (diff)
Add basic stats
Diffstat (limited to 'dispatch.go')
-rw-r--r--dispatch.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/dispatch.go b/dispatch.go
index 1d67d9e46..f974ea5ae 100644
--- a/dispatch.go
+++ b/dispatch.go
@@ -10,6 +10,14 @@ var resChan = make(chan *BaseMsg, 10)
var doneChan = make(chan bool)
var wg sync.WaitGroup
+var stats struct {
+ v8workerSend int
+ v8workerRespond int
+ v8workerRecv int
+ v8workerBytesSent int
+ v8workerBytesRecv int
+}
+
// There is a single global worker for this process.
// This file should be the only part of deno that directly access it, so that
// all interaction with V8 can go through a single point.
@@ -24,6 +32,9 @@ func createWorker() {
}
func recv(buf []byte) (response []byte) {
+ stats.v8workerRecv++
+ stats.v8workerBytesRecv += len(buf)
+
msg := &BaseMsg{}
check(proto.Unmarshal(buf, msg))
assert(len(msg.Payload) > 0, "BaseMsg has empty payload.")
@@ -38,6 +49,10 @@ func recv(buf []byte) (response []byte) {
response = r
}
}
+ if response != nil {
+ stats.v8workerRespond++
+ stats.v8workerBytesSent += len(response)
+ }
return response
}
@@ -79,6 +94,8 @@ func DispatchLoop() {
case msg := <-resChan:
out, err := proto.Marshal(msg)
err = worker.SendBytes(out)
+ stats.v8workerSend++
+ stats.v8workerBytesSent += len(out)
exitOnError(err)
case <-doneChan:
// All goroutines have completed. Now we can exit main().