X-Git-Url: http://nitlanguage.org diff --git a/lib/hash_debug.nit b/lib/hash_debug.nit index d25c671..5caf83d 100644 --- a/lib/hash_debug.nit +++ b/lib/hash_debug.nit @@ -29,8 +29,8 @@ # at callers of `HashCollection::gt_collide` and `HashCollection::st_collide`. module hash_debug -intrude import standard::collection::hash_collection -import standard +intrude import core::collection::hash_collection +import core redef class Sys # Number of calls of `HashCollection::node_at_idx` @@ -55,6 +55,13 @@ redef class Sys # Total capacity of hash collections receiver `HashCollection::store` var st_tot_cap = 0 + # Number of calls of `HashCollection::enlarge` + var en_count = 0 + # Total length of hash collections receiver of `HashCollection::enlarge` + var en_tot_length = 0 + # Total capacity of hash collections receiver `HashCollection::enlarge` + var en_tot_cap = 0 + private fun div(n,d: Int): String do if d == 0 then return "NA" @@ -90,6 +97,11 @@ number of collisions: {{{st_coll}}} ({{{div(st_coll*100,st_count)}}}%) average length of collisions: {{{div(st_tot_coll,st_coll)}}} average length of considered collections: {{{div(st_tot_length,sys.st_count)}}} average capacity or considered collections: {{{div(st_tot_cap,sys.st_count)}}} ({{{div(st_tot_cap*100,st_tot_length)}}}%) + +ENLARGE: +number of enlarge: {{{en_count}}} +average length of considered collections: {{{div(en_tot_length,sys.en_count)}}} +average capacity or considered collections: {{{div(en_tot_cap,sys.en_count)}}} ({{{div(en_tot_cap*100,en_tot_length)}}}%) ~~~~~~""" end @@ -121,11 +133,11 @@ do super end -redef class HashCollection[K,N] +redef class HashCollection[K] redef fun node_at_idx(i,k) do sys.gt_count += 1 - sys.gt_tot_length += _length + sys.gt_tot_length += _the_length sys.gt_tot_cap += _capacity var c = _array[i] if c != null and c._next_in_bucklet != null then gt_collide(i,k) @@ -133,10 +145,18 @@ redef class HashCollection[K,N] return super end + redef fun enlarge(c) + do + super + sys.en_count += 1 + sys.en_tot_length += _the_length + sys.en_tot_cap += _capacity + end + # Count and update length of collisions for `node_at_idx` # Note for dynamic call-graph analysis: callers of this functions are # responsible of collisions. - private fun gt_collide(i: Int, k: K) + fun gt_collide(i: Int, k: K) do var c = _array[i] sys.gt_coll += 1 @@ -150,7 +170,7 @@ redef class HashCollection[K,N] do sys.st_count += 1 if _array[i] != null then st_collide(i,n) - sys.st_tot_length += _length + sys.st_tot_length += _the_length sys.st_tot_cap += _capacity super @@ -159,7 +179,7 @@ redef class HashCollection[K,N] # Count and update length of collisions for `store` # Note for dynamic call-graph analysis: callers of this functions are # responsible of collisions. - private fun st_collide(i: Int, n: N) + fun st_collide(i: Int, n: N) do var c = _array[i] sys.st_coll += 1