shithub: mc

Download patch

ref: befeeb302c131fc318430bbdcdff2a5d3d18c6d0
parent: 509d071791cc2c008759f637931b7afea73c083b
author: Ori Bernstein <ori@eigenstate.org>
date: Sat Sep 9 19:51:17 EDT 2017

Add hash table htget benchmark.

--- a/bench/hashit.myr
+++ b/bench/hashit.myr
@@ -3,20 +3,28 @@
 
 const main = {
 	testr.bench([
-		[.name="hashstr", .fn={ctx; 
+		[.name="hashstr", .fn={ctx;
 			for var i = 0; i < 1000; i++
 				std.strhash("foobar")
 			;;
 		}],
-		[.name="hashint", .fn={ctx;
+		[.name="hashint", .fn={ctx
 			for var i = 0; i < 1000; i++
 				std.inthash(123)
 			;;
 		}],
-		[.name="hashlongstr", .fn={ctx;
+		[.name="hashlongstr", .fn={ctx
 			for var i = 0; i < 1000; i++
 				std.strhash(a)
 			;;
+		}],
+		[.name="htget", .fn={ctx
+			var h = std.mkht(std.strhash, std.streq)
+			std.htput(h, "foo", 123)
+			for var i = 0; i < 1000; i++
+				std.htget(h, "foo")
+			;;
+			std.htfree(h)
 		}]
 	][:])
 }