From cd38ad029147d1ff83d5641126f13464e00da7ff Mon Sep 17 00:00:00 2001
From: Hans Moog <hm@mkjc.net>
Date: Tue, 16 Jul 2019 14:48:14 +0200
Subject: [PATCH] Feat: added benchmark for signature verification

---
 main.go                                       |  3 ++-
 .../transactionspammer/transactionspammer.go  |  2 ++
 .../bundleprocessor/bundleprocessor_test.go   | 25 +++++++++++++++++++
 3 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/main.go b/main.go
index d2e0f90a..99011bd1 100644
--- a/main.go
+++ b/main.go
@@ -4,6 +4,7 @@ import (
 	"github.com/iotaledger/goshimmer/packages/node"
 	"github.com/iotaledger/goshimmer/plugins/analysis"
 	"github.com/iotaledger/goshimmer/plugins/autopeering"
+	"github.com/iotaledger/goshimmer/plugins/bundleprocessor"
 	"github.com/iotaledger/goshimmer/plugins/cli"
 	"github.com/iotaledger/goshimmer/plugins/gossip"
 	"github.com/iotaledger/goshimmer/plugins/gracefulshutdown"
@@ -25,7 +26,7 @@ func main() {
 		gossip.PLUGIN,
 		//gossip_on_solidification.PLUGIN,
 		tangle.PLUGIN,
-		//bundleprocessor.PLUGIN,
+		bundleprocessor.PLUGIN,
 		analysis.PLUGIN,
 		gracefulshutdown.PLUGIN,
 		tipselection.PLUGIN,
diff --git a/packages/transactionspammer/transactionspammer.go b/packages/transactionspammer/transactionspammer.go
index 80387272..936519f9 100644
--- a/packages/transactionspammer/transactionspammer.go
+++ b/packages/transactionspammer/transactionspammer.go
@@ -44,6 +44,8 @@ func Start(tps uint) {
 							totalSentCounter++
 
 							tx := value_transaction.New()
+							tx.SetHead(true)
+							tx.SetTail(true)
 							tx.SetValue(totalSentCounter)
 							tx.SetBranchTransactionHash(tipselection.GetRandomTip())
 							tx.SetTrunkTransactionHash(tipselection.GetRandomTip())
diff --git a/plugins/bundleprocessor/bundleprocessor_test.go b/plugins/bundleprocessor/bundleprocessor_test.go
index f8966e3d..06539a00 100644
--- a/plugins/bundleprocessor/bundleprocessor_test.go
+++ b/plugins/bundleprocessor/bundleprocessor_test.go
@@ -21,6 +21,31 @@ import (
 
 var seed = client.NewSeed("YFHQWAUPCXC9S9DSHP9NDF9RLNPMZVCMSJKUKQP9SWUSUCPRQXCMDVDVZ9SHHESHIQNCXWBJF9UJSWE9Z", consts.SecurityLevelMedium)
 
+func Benchmark(b *testing.B) {
+	bundleFactory := client.NewBundleFactory()
+	bundleFactory.AddInput(seed.GetAddress(0), -400)
+	bundleFactory.AddOutput(seed.GetAddress(1), 400, "Testmessage")
+	bundleFactory.AddOutput(client.NewAddress("SJKUKQP9SWUSUCPRQXCMDVDVZ9SHHESHIQNCXWBJF9UJSWE9ZYFHQWAUPCXC9S9DSHP9NDF9RLNPMZVCM"), 400, "Testmessage")
+
+	generatedBundle := bundleFactory.GenerateBundle(tipselection.GetRandomTip(), tipselection.GetRandomTip())
+
+	b.ResetTimer()
+
+	var wg sync.WaitGroup
+
+	for i := 0; i < b.N; i++ {
+		wg.Add(1)
+
+		go func() {
+			ValidateSignatures(generatedBundle.GetEssenceHash(), generatedBundle.GetTransactions())
+
+			wg.Done()
+		}()
+	}
+
+	wg.Wait()
+}
+
 func TestValidateSignatures(t *testing.T) {
 	bundleFactory := client.NewBundleFactory()
 	bundleFactory.AddInput(seed.GetAddress(0), -400)
-- 
GitLab