mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 20:38:55 +00:00
Add basic stats
This commit is contained in:
parent
59534fb9e3
commit
a1c0862047
17
dispatch.go
17
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().
|
||||
|
@ -85,15 +85,17 @@ func deno(inputFn string) (actual []byte, cachedir string, err error) {
|
||||
}
|
||||
|
||||
func integrationTestSetup() {
|
||||
startServer()
|
||||
cwd, err := os.Getwd()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
if denoFn == "" {
|
||||
startServer()
|
||||
cwd, err := os.Getwd()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
denoFn = path.Join(cwd, "deno")
|
||||
}
|
||||
denoFn = path.Join(cwd, "deno")
|
||||
}
|
||||
|
||||
func TestIntegration(t *testing.T) {
|
||||
func TestIntegrationFiles(t *testing.T) {
|
||||
integrationTestSetup()
|
||||
outFiles := listTestFiles()
|
||||
for _, outFile := range outFiles {
|
||||
@ -103,7 +105,7 @@ func TestIntegration(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestUrlArgs(t *testing.T) {
|
||||
func TestIntegrationUrlArgs(t *testing.T) {
|
||||
integrationTestSetup()
|
||||
|
||||
// Using good port 4545
|
||||
|
Loading…
Reference in New Issue
Block a user