Utils: Moving_average: use int64 for total
This commit is contained in:
parent
92c339f732
commit
70491aea8c
@ -272,14 +272,15 @@ module Real = struct
|
|||||||
P2p_connection_pool.write_all pool msg ;
|
P2p_connection_pool.write_all pool msg ;
|
||||||
Lwt.ignore_result (lwt_debug "message broadcasted")
|
Lwt.ignore_result (lwt_debug "message broadcasted")
|
||||||
|
|
||||||
|
let pool { pool } = pool
|
||||||
end
|
end
|
||||||
|
|
||||||
module Fake = struct
|
module Fake = struct
|
||||||
|
|
||||||
let id = Identity.generate (Crypto_box.make_target 0.)
|
let id = Identity.generate (Crypto_box.make_target 0.)
|
||||||
let empty_stat = {
|
let empty_stat = {
|
||||||
Stat.total_sent = 0 ;
|
Stat.total_sent = 0L ;
|
||||||
total_recv = 0 ;
|
total_recv = 0L ;
|
||||||
current_inflow = 0 ;
|
current_inflow = 0 ;
|
||||||
current_outflow = 0 ;
|
current_outflow = 0 ;
|
||||||
}
|
}
|
||||||
|
@ -45,12 +45,19 @@ end
|
|||||||
module Stat = struct
|
module Stat = struct
|
||||||
|
|
||||||
type t = {
|
type t = {
|
||||||
total_sent : int ;
|
total_sent : int64 ;
|
||||||
total_recv : int ;
|
total_recv : int64 ;
|
||||||
current_inflow : int ;
|
current_inflow : int ;
|
||||||
current_outflow : int ;
|
current_outflow : int ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let empty = {
|
||||||
|
total_sent = 0L ;
|
||||||
|
total_recv = 0L ;
|
||||||
|
current_inflow = 0 ;
|
||||||
|
current_outflow = 0 ;
|
||||||
|
}
|
||||||
|
|
||||||
let print_size ppf sz =
|
let print_size ppf sz =
|
||||||
let ratio n = (float_of_int sz /. float_of_int (1 lsl n)) in
|
let ratio n = (float_of_int sz /. float_of_int (1 lsl n)) in
|
||||||
if sz < 1 lsl 10 then
|
if sz < 1 lsl 10 then
|
||||||
|
@ -18,7 +18,7 @@ module Inttbl = Hashtbl.Make(struct
|
|||||||
type t = {
|
type t = {
|
||||||
id: int;
|
id: int;
|
||||||
alpha: int ;
|
alpha: int ;
|
||||||
mutable total: int ;
|
mutable total: int64 ;
|
||||||
mutable current: int ;
|
mutable current: int ;
|
||||||
mutable average: int ;
|
mutable average: int ;
|
||||||
}
|
}
|
||||||
@ -66,19 +66,19 @@ let create =
|
|||||||
incr cpt ;
|
incr cpt ;
|
||||||
assert (0. < alpha && alpha <= 1.) ;
|
assert (0. < alpha && alpha <= 1.) ;
|
||||||
let alpha = int_of_float (1000. *. alpha) in
|
let alpha = int_of_float (1000. *. alpha) in
|
||||||
let c = { id ; alpha ; total = 0 ; current = 0 ; average = init } in
|
let c = { id ; alpha ; total = 0L ; current = 0 ; average = init } in
|
||||||
Inttbl.add counters id c ;
|
Inttbl.add counters id c ;
|
||||||
c
|
c
|
||||||
|
|
||||||
let add c x =
|
let add c x =
|
||||||
c.total <- c.total + x ;
|
c.total <- Int64.(add c.total (of_int x)) ;
|
||||||
c.current <- c.current + x
|
c.current <- c.current + x
|
||||||
|
|
||||||
let destroy c =
|
let destroy c =
|
||||||
Inttbl.remove counters c.id
|
Inttbl.remove counters c.id
|
||||||
|
|
||||||
type stat = {
|
type stat = {
|
||||||
total: int ;
|
total: int64 ;
|
||||||
average: int ;
|
average: int ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ val on_update: (unit -> unit) -> unit
|
|||||||
val updated: unit Lwt_condition.t
|
val updated: unit Lwt_condition.t
|
||||||
|
|
||||||
type stat = {
|
type stat = {
|
||||||
total: int ;
|
total: int64 ;
|
||||||
average: int ;
|
average: int ;
|
||||||
}
|
}
|
||||||
val stat: t -> stat
|
val stat: t -> stat
|
||||||
|
Loading…
Reference in New Issue
Block a user