Enlightenment CVS committal
Author : ningerso
Project : e17
Module : libs/ecore
Dir : e17/libs/ecore/src/lib/ecore
Modified Files:
Ecore_Data.h ecore_hash.c ecore_strings.c ecore_value.c
Log Message:
Add basic stat output to hash for testing.
Expose hash output functions for ecore_string.
Move mask calculation outside inner loop for ecore_str_hash.
===================================================================
RCS file: /cvs/e/e17/libs/ecore/src/lib/ecore/Ecore_Data.h,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -3 -r1.27 -r1.28
--- Ecore_Data.h 4 Jan 2007 07:45:39 -0000 1.27
+++ Ecore_Data.h 16 Jan 2007 01:27:01 -0000 1.28
@@ -248,6 +248,7 @@
EAPI int ecore_hash_set(Ecore_Hash *hash, void *key, void *value);
EAPI void *ecore_hash_remove(Ecore_Hash *hash, const void *key);
EAPI void ecore_hash_dump_graph(Ecore_Hash *hash);
+ EAPI void ecore_hash_dump_stats(Ecore_Hash *hash);
typedef struct _ecore_path_group Ecore_Path_Group;
@@ -360,6 +361,8 @@
EAPI void ecore_string_shutdown(void);
EAPI const char *ecore_string_instance(const char *string);
EAPI void ecore_string_release(const char *string);
+ EAPI void ecore_string_hash_dump_graph();
+ EAPI void ecore_string_hash_dump_stats();
typedef struct _Ecore_Tree_Node Ecore_Tree_Node;
===================================================================
RCS file: /cvs/e/e17/libs/ecore/src/lib/ecore/ecore_hash.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -3 -r1.32 -r1.33
--- ecore_hash.c 11 Jan 2007 23:42:21 -0000 1.32
+++ ecore_hash.c 16 Jan 2007 01:27:01 -0000 1.33
@@ -318,6 +318,33 @@
printf("%d\t0\n", i);
}
+/**
+ * Prints the distribution of the given hash table for graphing.
+ * @param hash The given hash table.
+ */
+EAPI void
+ecore_hash_dump_stats(Ecore_Hash *hash)
+{
+ unsigned int i;
+ double variance, sum_n_2 = 0, sum_n = 0;
+
+ for (i = 0; i < ecore_prime_table[hash->size]; i++)
+ {
+ if (hash->buckets[i])
+ {
+ int n = 0;
+ Ecore_Hash_Node *node;
+ for (node = hash->buckets[i]; node; node = node->next)
+ n++;
+ sum_n_2 += ((double)n * (double)n);
+ sum_n += (double)n;
+ }
+ }
+ variance = (sum_n_2 - ((sum_n * sum_n) / (double)i)) / (double)i;
+ printf("Average length: %f\n\tvariance^2: %f\n", (sum_n / (double)i),
+ variance);
+}
+
static int
_ecore_hash_bucket_destroy(Ecore_Hash_Node *list, Ecore_Free_Cb keyd,
Ecore_Free_Cb valued)
{
===================================================================
RCS file: /cvs/e/e17/libs/ecore/src/lib/ecore/ecore_strings.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -3 -r1.14 -r1.15
--- ecore_strings.c 27 Oct 2006 03:52:28 -0000 1.14
+++ ecore_strings.c 16 Jan 2007 01:27:01 -0000 1.15
@@ -102,6 +102,18 @@
}
}
+EAPI void
+ecore_string_hash_dump_graph()
+{
+ ecore_hash_dump_graph(ecore_strings);
+}
+
+EAPI void
+ecore_string_hash_dump_stats()
+{
+ ecore_hash_dump_stats(ecore_strings);
+}
+
/**
* Shutdown the ecore string internal structures
*/
===================================================================
RCS file: /cvs/e/e17/libs/ecore/src/lib/ecore/ecore_value.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -3 -r1.10 -r1.11
--- ecore_value.c 6 Sep 2006 07:06:55 -0000 1.10
+++ ecore_value.c 16 Jan 2007 01:27:01 -0000 1.11
@@ -67,16 +67,18 @@
ecore_str_hash(const void *key)
{
int i;
+ unsigned int mask;
unsigned int value = 0;
const char *k = key;
if (!k)
return 0;
+ mask = (sizeof(unsigned int) * 8) - 1;
+
for (i = 0; k[i] != '\0'; i++)
{
- value ^= ((unsigned int) k[i] << ((i * 5) %
- (sizeof(unsigned int) * 8)));
+ value ^= ((unsigned int) k[i] << ((i * 5) & mask));
}
return value;
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs