develooper Front page | perl.perl6.internals | Postings from May 2005

Re: wanted: hash stress tests

Thread Previous | Thread Next
From:
Bob Rogers
Date:
May 24, 2005 18:07
Subject:
Re: wanted: hash stress tests
Message ID:
17043.53195.587760.700227@rgrjr.dyndns.org
   From: Leopold Toetsch <lt@toetsch.at>
   Date: Sun, 22 May 2005 16:58:00 +0200

   Bob Rogers wrote:

   > Below please find an additional test case for t/pmc/hash.t that defines
   > 
   >>50K keys, while checking that earlier entries are still present.  This
   > 
   > takes about 0.8 sec on my 1.8GHz AMD box, tunable by increasing I22.  Is
   > this the sort of thing you had in mind?

   Yeah. Thanks. It's OTOH failing here, I've too look at it, then it'll go 
   in. Another one which additionally deletes keys would be great.

This patch adds deletion to the same case.  Testing also caught a
missing label in the original version, for a branch that was never
taken.

					-- Bob Rogers
					   http://rgrjr.dyndns.org/

------------------------------------------------------------------------
Index: t/pmc/hash.t
===================================================================
--- t/pmc/hash.t	(revision 8160)
+++ t/pmc/hash.t	(working copy)
@@ -312,6 +312,7 @@
 print_value:
 	S2 = hash[S1]
 	print S2
+print_end:
 	print "\n"
 	key_index = key_index + step
 	count = count - 1
@@ -319,6 +320,23 @@
 ret:
 .end
 
+.sub delete_multiple_keys prototyped
+	.param pmc hash
+	.param int key_index
+	.param int step
+	.param int count
+
+again:
+	if count <= 0 goto ret
+	S0 = key_index
+	S1 = concat "key", S0
+	delete hash[S1]
+	key_index = key_index + step
+	count = count - 1
+	goto again
+ret:
+.end
+
 .sub _main @MAIN
 	new	P30, .Hash
 	print "round 1\n"
@@ -338,6 +356,10 @@
 	set_multiple_keys(P30, I22, I29, I22)
 	print_multiple_keys(P30, I29, I30, I20)
 	print_multiple_keys(P30, I22, I30, I20)
+	print "round 4\n"
+	delete_multiple_keys(P30, I22, I29, I22)
+	print_multiple_keys(P30, I29, I30, I20)
+	print_multiple_keys(P30, I22, I30, I20)
 	print "done.\n"
 .end
 CODE
@@ -359,6 +381,13 @@
 key50000 => value50000
 key51000 => value51000
 key52000 => value52000
+round 4
+key1 => value1
+key1001 => value1001
+key2001 => value2001
+key50000 => (undef)
+key51000 => (undef)
+key52000 => (undef)
 done.
 OUTPUT
 

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About