diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2018-10-05 19:21:15 +0200 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2018-10-11 15:45:51 -0400 |
commit | 51f9331ecb50afeafd0fa2ca8336e75aa374465e (patch) | |
tree | 7f3c76670760feea91d5fb260037a1d80c94d5a0 /js/metrics_test.ts | |
parent | 951e5def9856ee15be52c153a1d2cb7dd73f0da8 (diff) |
Add deno.metrics()
Diffstat (limited to 'js/metrics_test.ts')
-rw-r--r-- | js/metrics_test.ts | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/js/metrics_test.ts b/js/metrics_test.ts new file mode 100644 index 000000000..6954ae2ce --- /dev/null +++ b/js/metrics_test.ts @@ -0,0 +1,24 @@ +// Copyright 2018 the Deno authors. All rights reserved. MIT license. +import { test, assert } from "./test_util.ts"; +import * as deno from "deno"; + +test(function metrics() { + const m1 = deno.metrics(); + assert(m1.opsDispatched > 0); + assert(m1.opsCompleted > 0); + assert(m1.bytesSentControl > 0); + assert(m1.bytesSentData >= 0); + assert(m1.bytesReceived > 0); + + // Write to stdout to ensure a "data" message gets sent instead of just + // control messages. + const dataMsg = new Uint8Array([41, 42, 43]); + deno.stdout.write(dataMsg); + + const m2 = deno.metrics(); + assert(m2.opsDispatched > m1.opsDispatched); + assert(m2.opsCompleted > m1.opsCompleted); + assert(m2.bytesSentControl > m1.bytesSentControl); + assert(m2.bytesSentData >= m1.bytesSentData + dataMsg.byteLength); + assert(m2.bytesReceived > m1.bytesReceived); +}); |