From 32a850a9ff42d775f0d0ee0868db88f4f748504d Mon Sep 17 00:00:00 2001
From: Gav Wood <i@gavwood.com>
Date: Wed, 20 May 2015 09:59:18 +0200
Subject: [PATCH] Trie timing.

---
 exp/main.cpp | 36 ++++++++++++++++++++++++++++++++----
 1 file changed, 32 insertions(+), 4 deletions(-)

diff --git a/exp/main.cpp b/exp/main.cpp
index d31306496..47efe576a 100644
--- a/exp/main.cpp
+++ b/exp/main.cpp
@@ -34,6 +34,9 @@
 #include <functional>
 #include <boost/filesystem.hpp>
 #include <boost/algorithm/string.hpp>
+#include <libdevcore/TrieDB.h>
+#include <libdevcore/TrieHash.h>
+/*
 #include <libdevcore/RangeMask.h>
 #include <libdevcore/Log.h>
 #include <libdevcore/Common.h>
@@ -41,7 +44,6 @@
 #include <libdevcore/RLP.h>
 #include <libdevcore/TransientDirectory.h>
 #include <libdevcore/CommonIO.h>
-#include <libdevcore/TrieDB.h>
 #include <libdevcrypto/SecretStore.h>
 #include <libp2p/All.h>
 #include <libethcore/ProofOfWork.h>
@@ -55,17 +57,43 @@
 #include <liblll/All.h>
 #include <libwhisper/WhisperPeer.h>
 #include <libwhisper/WhisperHost.h>
-#include <test/JsonSpiritHeaders.h>
+#include <test/JsonSpiritHeaders.h>*/
 using namespace std;
 using namespace dev;
-using namespace dev::eth;
+/*using namespace dev::eth;
 using namespace dev::p2p;
 using namespace dev::shh;
 namespace js = json_spirit;
 namespace fs = boost::filesystem;
-
+*/
 #if 1
 
+int main()
+{
+	cdebug << "EXP";
+	vector<bytes> data;
+	for (unsigned i = 0; i < 10000; ++i)
+		data.push_back(rlp(i));
+
+	h256 ret;
+	DEV_TIMED(triedb)
+	{
+		MemoryDB mdb;
+		GenericTrieDB<MemoryDB> t(&mdb);
+		t.init();
+		unsigned i = 0;
+		for (auto const& d: data)
+			t.insert(rlp(i++), d);
+		ret = t.root();
+	}
+	cdebug << ret;
+	DEV_TIMED(hash256)
+		ret = orderedTrieRoot(data);
+	cdebug << ret;
+}
+
+#elif 0
+
 int main()
 {
 	KeyManager keyman;