1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-25 00:29:09 -05:00
denoland-deno/cli/metrics.rs

74 lines
1.9 KiB
Rust
Raw Normal View History

// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
#[derive(Default, Debug)]
pub struct Metrics {
pub ops_dispatched: u64,
pub ops_dispatched_sync: u64,
pub ops_dispatched_async: u64,
pub ops_dispatched_async_unref: u64,
pub ops_completed: u64,
pub ops_completed_sync: u64,
pub ops_completed_async: u64,
pub ops_completed_async_unref: u64,
pub bytes_sent_control: u64,
pub bytes_sent_data: u64,
pub bytes_received: u64,
pub resolve_count: u64,
}
impl Metrics {
2020-09-05 20:34:02 -04:00
fn op_dispatched(
&mut self,
bytes_sent_control: usize,
bytes_sent_data: usize,
) {
self.ops_dispatched += 1;
2020-09-05 20:34:02 -04:00
self.bytes_sent_control += bytes_sent_control as u64;
self.bytes_sent_data += bytes_sent_data as u64;
}
2020-09-05 20:34:02 -04:00
fn op_completed(&mut self, bytes_received: usize) {
self.ops_completed += 1;
2020-09-05 20:34:02 -04:00
self.bytes_received += bytes_received as u64;
}
pub fn op_sync(
&mut self,
2020-09-05 20:34:02 -04:00
bytes_sent_control: usize,
bytes_sent_data: usize,
bytes_received: usize,
) {
self.ops_dispatched_sync += 1;
self.op_dispatched(bytes_sent_control, bytes_sent_data);
self.ops_completed_sync += 1;
self.op_completed(bytes_received);
}
pub fn op_dispatched_async(
&mut self,
2020-09-05 20:34:02 -04:00
bytes_sent_control: usize,
bytes_sent_data: usize,
) {
self.ops_dispatched_async += 1;
self.op_dispatched(bytes_sent_control, bytes_sent_data)
}
pub fn op_dispatched_async_unref(
&mut self,
2020-09-05 20:34:02 -04:00
bytes_sent_control: usize,
bytes_sent_data: usize,
) {
self.ops_dispatched_async_unref += 1;
self.op_dispatched(bytes_sent_control, bytes_sent_data)
}
2020-09-05 20:34:02 -04:00
pub fn op_completed_async(&mut self, bytes_received: usize) {
self.ops_completed_async += 1;
self.op_completed(bytes_received);
}
2020-09-05 20:34:02 -04:00
pub fn op_completed_async_unref(&mut self, bytes_received: usize) {
self.ops_completed_async_unref += 1;
self.op_completed(bytes_received);
}
}