From 6519691e79c73710d609035797673e0b6a4febe8 Mon Sep 17 00:00:00 2001 From: andrea Date: Sun, 17 May 2015 09:56:25 +0200 Subject: [PATCH] Added script to measure connetion timing --- ChangeLog.txt | 1 + .../benchmark/connectionTimings.groovy | 34 +++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 tools_scripts/benchmark/connectionTimings.groovy diff --git a/ChangeLog.txt b/ChangeLog.txt index 5c656f8e..fca744bf 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -11,6 +11,7 @@ Version 0.7: Removed OSGi bundle, developer time burner Fixed github issue #30, returning error on mapdb file not deleted that corrupt reiterated builds Added handling of allow_anonymous clients (as in mosquitto issue #34) + Modified the password_file format to use password soterd in sha256 and not plain text Version 0.6: Fix issue #42, bad password file path composition diff --git a/tools_scripts/benchmark/connectionTimings.groovy b/tools_scripts/benchmark/connectionTimings.groovy new file mode 100644 index 00000000..7522af14 --- /dev/null +++ b/tools_scripts/benchmark/connectionTimings.groovy @@ -0,0 +1,34 @@ +@GrabResolver(name='Paho', root='https://repo.eclipse.org/content/repositories/paho-releases/') +@Grab(group='org.eclipse.paho', module='mqtt-client', version='0.4.0') + +/** + * Ths script is meant to measure the connection mean time from a client. + * It loops connecting and disconnecting to the broker. + * */ + +import org.eclipse.paho.client.mqttv3.MqttClient +import org.eclipse.paho.client.mqttv3.MqttMessage +import org.eclipse.paho.client.mqttv3.persist.MqttDefaultFilePersistence + +String tmpDir = System.getProperty("java.io.tmpdir") +MqttDefaultFilePersistence dataStore = new MqttDefaultFilePersistence(tmpDir) + +MqttClient client = new MqttClient("tcp://localhost:1883", "ReconnectingClient", dataStore) +10.times { + println "conneting.." + long start = System.currentTimeMillis() + client.connect() + long time = System.currentTimeMillis() - start + print "took ${time} ms " + + MqttMessage message = new MqttMessage('Hello world!!'.bytes) + message.setQos(0) + long startPub = System.currentTimeMillis() + client.getTopic("log").publish(message) + long pubTime = System.currentTimeMillis() - startPub + print " pub (qos 0): ${pubTime} ms " + + client.disconnect() + println "disconnected" +} +println "Finished" \ No newline at end of file