You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ac...@apache.org on 2018/10/15 18:47:55 UTC

[1/3] qpid-proton git commit: NO-JIRA: [go] example receiver grants credit like other examples

Repository: qpid-proton
Updated Branches:
  refs/heads/master 4a9f3b986 -> 994db75c9


NO-JIRA: [go] example receiver grants credit like other examples

Default to N credits where N is expected message count.
-prefetch option specifies a credit window instead


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/7856d2dc
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/7856d2dc
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/7856d2dc

Branch: refs/heads/master
Commit: 7856d2dc99ea50c2b07078c3544e68ca454023a3
Parents: 4a9f3b9
Author: Alan Conway <ac...@redhat.com>
Authored: Mon Oct 15 10:22:54 2018 -0400
Committer: Alan Conway <ac...@redhat.com>
Committed: Mon Oct 15 10:22:54 2018 -0400

----------------------------------------------------------------------
 go/examples/electron/receive.go | 15 +++++----
 tests/example-benchmark.sh      | 65 ++++++++++++++++++++++++++++++++++++
 2 files changed, 74 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7856d2dc/go/examples/electron/receive.go
----------------------------------------------------------------------
diff --git a/go/examples/electron/receive.go b/go/examples/electron/receive.go
index 9cab2eb..774e589 100644
--- a/go/examples/electron/receive.go
+++ b/go/examples/electron/receive.go
@@ -24,10 +24,11 @@ import (
 	"fmt"
 	"log"
 	"os"
-	"qpid.apache.org/amqp"
-	"qpid.apache.org/electron"
 	"strings"
 	"sync"
+
+	"qpid.apache.org/amqp"
+	"qpid.apache.org/electron"
 )
 
 // Usage and command-line flags
@@ -39,8 +40,8 @@ URLs are of the form "amqp://<host>:<port>/<amqp-address>"
 	flag.PrintDefaults()
 }
 
-var count = flag.Uint64("count", 1, "Stop after receiving this many messages in total")
-var prefetch = flag.Int("prefetch", 0, "enable a pre-fetch window to improve throughput")
+var count = flag.Int("count", 1, "Stop after receiving this many messages in total")
+var prefetch = flag.Int("prefetch", 0, "enable a pre-fetch window for flow control")
 var debug = flag.Bool("debug", false, "Print detailed debug output")
 var debugf = func(format string, data ...interface{}) {} // Default no debugging output
 
@@ -80,8 +81,10 @@ func main() {
 			connections <- c // Save connection so we can Close() when main() ends
 			addr := strings.TrimPrefix(url.Path, "/")
 			opts := []electron.LinkOption{electron.Source(addr)}
-			if *prefetch > 0 {
+			if *prefetch > 0 { // Use a pre-fetch window
 				opts = append(opts, electron.Capacity(*prefetch), electron.Prefetch(true))
+			} else { // Grant credit for all expected messages at once
+				opts = append(opts, electron.Capacity(*count), electron.Prefetch(false))
 			}
 			r, err := c.Receiver(opts...)
 			fatalIf(err)
@@ -103,7 +106,7 @@ func main() {
 	fmt.Printf("Listening on %d connections\n", len(urls))
 
 	// print each message until the count is exceeded.
-	for i := uint64(0); i < *count; i++ {
+	for i := 0; i < *count; i++ {
 		m := <-messages
 		debugf("%v\n", m.Body())
 	}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/7856d2dc/tests/example-benchmark.sh
----------------------------------------------------------------------
diff --git a/tests/example-benchmark.sh b/tests/example-benchmark.sh
new file mode 100755
index 0000000..b6ca21c
--- /dev/null
+++ b/tests/example-benchmark.sh
@@ -0,0 +1,65 @@
+#!/bin/bash
+# Simple script to time running the examples in various languages.
+# Should be run in the build directory.
+# Use command line to run different combinations.
+# For example to run C broker, Go sender and C++ receiver pass arguments: C GO CPP
+
+MESSAGES=100000
+CREDIT=100
+
+BLD=$(pwd)
+
+C=$BLD/c/examples
+C_BROKER="$C/broker"
+C_SEND="$C/send localhost amqp x $MESSAGES"
+C_RECV="$C/receive localhost amqp x $MESSAGES"
+
+GO=$BLD/go/examples/electron
+GO_BROKER="$GO/broker"
+GO_SEND="$GO/send -count $MESSAGES /x"
+GO_RECV="$GO/receive -count $MESSAGES /x"
+
+CPP=$BLD/cpp/examples
+CPP_BROKER="$CPP/broker"
+CPP_SEND="$CPP/simple_send -a /x -m $MESSAGES"
+CPP_RECV="$CPP/simple_recv -a /x -m $MESSAGES"
+
+amqp_busy() { ss -tlp | grep $* amqp; }
+
+start_broker() {
+    amqp_busy && { "amqp port busy"; exit 1; }
+    "$@" & BROKER_PID=$!
+    until amqp_busy -q; do sleep .1; done
+}
+
+stop_broker() {
+    kill $BROKER_PID
+    wait $BROKER_PID 2> /dev/null
+}
+
+run() {
+    echo
+    echo "run: $*"
+    BROKER=${!1}
+    SEND=${!2}
+    RECV=${!3}
+    start_broker $BROKER
+    time {
+        $RECV > /dev/null& RECV_PID=$!
+        $SEND
+        wait $RECV_PID
+    }
+    stop_broker
+}
+
+if test -z "$*"; then
+    # By default run the broker/sender/receiver combo for each language
+    run C_BROKER C_SEND C_RECV
+    run GO_BROKER GO_SEND GO_RECV
+    run CPP_BROKER CPP_SEND CPP_RECV
+else
+    while test -n "$*"; do
+        run ${1}_BROKER ${2}_SEND ${3}_RECV
+        shift; shift; shift
+    done
+fi


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[2/3] qpid-proton git commit: NO-JIRA: Benchmark script for comparing examples in different languages

Posted by ac...@apache.org.
NO-JIRA: Benchmark script for comparing examples in different languages

Crude but effective throughput comparison that can run and combine examples
in different languages.


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/8b29f416
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/8b29f416
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/8b29f416

Branch: refs/heads/master
Commit: 8b29f416f108883c114740e31c49b33ef6805bff
Parents: 7856d2d
Author: Alan Conway <ac...@redhat.com>
Authored: Mon Oct 15 10:23:44 2018 -0400
Committer: Alan Conway <ac...@redhat.com>
Committed: Mon Oct 15 10:23:44 2018 -0400

----------------------------------------------------------------------
 tests/example-benchmark.sh | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8b29f416/tests/example-benchmark.sh
----------------------------------------------------------------------
diff --git a/tests/example-benchmark.sh b/tests/example-benchmark.sh
index b6ca21c..db9298e 100755
--- a/tests/example-benchmark.sh
+++ b/tests/example-benchmark.sh
@@ -5,7 +5,6 @@
 # For example to run C broker, Go sender and C++ receiver pass arguments: C GO CPP
 
 MESSAGES=100000
-CREDIT=100
 
 BLD=$(pwd)
 
@@ -17,7 +16,7 @@ C_RECV="$C/receive localhost amqp x $MESSAGES"
 GO=$BLD/go/examples/electron
 GO_BROKER="$GO/broker"
 GO_SEND="$GO/send -count $MESSAGES /x"
-GO_RECV="$GO/receive -count $MESSAGES /x"
+GO_RECV="$GO/receive -count $MESSAGES -prefetch 100 /x"
 
 CPP=$BLD/cpp/examples
 CPP_BROKER="$CPP/broker"


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[3/3] qpid-proton git commit: NO-JIRA: [c, cpp] monkey-patch python 2.7 unittest features for python 2.6

Posted by ac...@apache.org.
NO-JIRA: [c,cpp] monkey-patch python 2.7 unittest features for python 2.6


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/994db75c
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/994db75c
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/994db75c

Branch: refs/heads/master
Commit: 994db75c949412c60b31abc4b4c2279ebb956201
Parents: 8b29f41
Author: Alan Conway <ac...@redhat.com>
Authored: Mon Oct 15 14:46:22 2018 -0400
Committer: Alan Conway <ac...@redhat.com>
Committed: Mon Oct 15 14:46:22 2018 -0400

----------------------------------------------------------------------
 c/examples/testme         |  2 +-
 cpp/examples/testme       |  3 ++-
 tests/py/test_unittest.py | 28 ++++++++++++++++++++++++++++
 3 files changed, 31 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/994db75c/c/examples/testme
----------------------------------------------------------------------
diff --git a/c/examples/testme b/c/examples/testme
index c498293..a405679 100755
--- a/c/examples/testme
+++ b/c/examples/testme
@@ -21,7 +21,7 @@
 # Run the C examples and verify that they behave as expected.
 # Example executables must be in PATH
 
-import unittest
+from test_unittest import unittest
 
 from test_subprocess import Popen, Server, TestProcessError, check_output
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/994db75c/cpp/examples/testme
----------------------------------------------------------------------
diff --git a/cpp/examples/testme b/cpp/examples/testme
index 5f30f23..ed642e9 100755
--- a/cpp/examples/testme
+++ b/cpp/examples/testme
@@ -21,7 +21,8 @@
 # Run the C++ examples and verify that they behave as expected.
 # Example executables must be in PATH
 
-import unittest, sys, shutil, os, errno
+import sys, shutil, os, errno
+from test_unittest import  unittest
 from test_subprocess import Popen, TestProcessError, check_output
 import test_subprocess
 from os.path import dirname

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/994db75c/tests/py/test_unittest.py
----------------------------------------------------------------------
diff --git a/tests/py/test_unittest.py b/tests/py/test_unittest.py
new file mode 100644
index 0000000..afc863b
--- /dev/null
+++ b/tests/py/test_unittest.py
@@ -0,0 +1,28 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License
+#
+
+import unittest
+
+def assertMultiLineEqual(self, a, b, msg=None): self.assertEqual(a,b,msg)
+unittest.TestCase.assertMultiLineEqual = assertMultiLineEqual
+
+def assertIn(self, a, b, msg=None): self.assertTrue(a in b,msg)
+unittest.TestCase.assertIn = assertIn
+
+


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org