Permalink
Browse files

[feature] session: Add some stats

  • Loading branch information...
1 parent 6ce71ab commit c58bfdac33a2178799120c9d1419f1676781a65e @BourgerieQuentin BourgerieQuentin committed with Thomas Refis Jul 21, 2011
Showing with 31 additions and 1 deletion.
  1. +2 −1 libbase/weakHashtbl.ml
  2. +2 −0 libbase/weakHashtbl.mli
  3. +24 −0 libsession/channel.ml
  4. +3 −0 opabsl/mlbsl/bslSession.ml
View
@@ -75,6 +75,7 @@ module Make (HK : Hashtbl.HashedType)(HD : WeakedType) = struct
let relax t k =
t.strong <- S.remove (find t k) t.strong
-
+ let size t =
+ HT.length t.htbl
end
View
@@ -43,4 +43,6 @@ module Make :
val find : t -> key -> HD.t
+ val size : t -> int
+
end
View
@@ -203,6 +203,9 @@ module type M = functor (N : NETWORK) -> sig
(** Get a string representation of an [identity]. *)
val identity_to_string : identity -> string
+ (** Returns the numbers of stored channels. *)
+ val size : unit -> int
+
(** {6 Deprecated/Hack} *)
(** Fail on non local channel*)
val get_more : ('msg, 'ctx) t -> Obj.t option
@@ -289,6 +292,8 @@ let make scheduler =
val unserialize : ('msg, 'ctx) t -> N.serialized -> ('msg option -> unit) -> unit
+ val size : unit -> int
+
end = struct
type ('msg,'ctx) t = {
lid : int;
@@ -475,6 +480,14 @@ let make scheduler =
Hashtbl.add rcbhtbl chan.lid rcb
)
+ let size () =
+ let w = W.size weak in
+ #<If>
+ U.info "CHANNEL" "weak : %d; rhtbl : %d; rcbhtbl : %d; idset : %d" w
+ (Hashtbl.length rhtbl) (Hashtbl.length rcbhtbl) (IntSet.size !idset);
+ #<End>;
+ w
+
end
@@ -506,6 +519,8 @@ let make scheduler =
val relax : N.cid -> unit
+ val size : unit -> int
+
end = struct
type t
@@ -633,6 +648,13 @@ let make scheduler =
let e, cbs = Hashtbl.find entity_channels cid in
Hashtbl.replace entity_channels cid (e, rcb::cbs)
with Not_found -> Scheduler.push scheduler rcb
+
+ let size () =
+ let w = W.size weak in
+ #<If>
+ U.info "CHANNEL" "weak : %d; hash : %d" w (Hashtbl.length entity_channels);
+ #<End>;
+ w
end
@@ -875,4 +897,6 @@ let make scheduler =
release_all entity;
Entity.remove_entity entity
+ let size () = Entity.size () + Local.size ()
+
end in (module Implem : M)
@@ -1239,3 +1239,6 @@ let my_endpoint k =
##register force_gc : -> void
let force_gc = Gc.full_major
+
+##register size : -> int
+let size = Channel.size

0 comments on commit c58bfda

Please sign in to comment.