You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2007/06/10 00:31:10 UTC

svn commit: r545802 - in /activemq/activemq-cpp/trunk/src/decaf: Makefile.am configure.ac src/examples/main.cpp

Author: tabish
Date: Sat Jun  9 15:31:07 2007
New Revision: 545802

URL: http://svn.apache.org/viewvc?view=rev&rev=545802
Log:
https://issues.apache.org/activemq/browse/AMQCPP-103

Building up the Decaf Library

Added:
    activemq/activemq-cpp/trunk/src/decaf/src/examples/main.cpp
Modified:
    activemq/activemq-cpp/trunk/src/decaf/Makefile.am
    activemq/activemq-cpp/trunk/src/decaf/configure.ac

Modified: activemq/activemq-cpp/trunk/src/decaf/Makefile.am
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/Makefile.am?view=diff&rev=545802&r1=545801&r2=545802
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/Makefile.am (original)
+++ activemq/activemq-cpp/trunk/src/decaf/Makefile.am Sat Jun  9 15:31:07 2007
@@ -18,7 +18,7 @@
 # Since we don't strictly follow the GNU standard of having 'NEWS README AUTHORS ChangeLog' files
 AUTOMAKE_OPTIONS = foreign
 
-SUBDIRS = src/main
+SUBDIRS = src/main src/examples
 if BUILD_CPPUNIT_TESTS
   SUBDIRS += src/test
 endif

Modified: activemq/activemq-cpp/trunk/src/decaf/configure.ac
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/configure.ac?view=diff&rev=545802&r1=545801&r2=545802
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/configure.ac (original)
+++ activemq/activemq-cpp/trunk/src/decaf/configure.ac Sat Jun  9 15:31:07 2007
@@ -165,6 +165,7 @@
 AC_CONFIG_FILES(Makefile)
 AC_CONFIG_FILES(decaf.pc)
 AC_CONFIG_FILES(src/main/Makefile)
+AC_CONFIG_FILES(src/examples/Makefile)
 
 if test x$cppunit = xyes
 then

Added: activemq/activemq-cpp/trunk/src/decaf/src/examples/main.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/decaf/src/examples/main.cpp?view=auto&rev=545802
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/src/examples/main.cpp (added)
+++ activemq/activemq-cpp/trunk/src/decaf/src/examples/main.cpp Sat Jun  9 15:31:07 2007
@@ -0,0 +1,88 @@
+/*
+ * 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.
+ */
+
+// START SNIPPET: demo
+
+#include <decaf/lang/Thread.h>
+#include <decaf/lang/Runnable.h>
+#include <decaf/lang/Integer.h>
+#include <decaf/util/concurrent/CountDownLatch.h>
+#include <decaf/util/Config.h>
+#include <decaf/io/ByteArrayInputStream.h>
+#include <decaf/util/Date.h>
+
+#include <stdlib.h>
+#include <iostream>
+
+using namespace decaf::lang;
+using namespace decaf::io;
+using namespace decaf::util;
+using namespace decaf::util::concurrent;
+using namespace std;
+
+int main(int argc DECAF_UNUSED, char* argv[] DECAF_UNUSED) {
+
+    std::cout << "=====================================================\n";
+    std::cout << "Starting the example:" << std::endl;
+    std::cout << "-----------------------------------------------------\n";
+
+    const int bufferSize = 1024 * 2000;
+    const int totalRuns = 100;
+
+    const unsigned char* buffer = new unsigned char[bufferSize];
+    unsigned char* recvBuffer = new unsigned char[bufferSize];
+    long long startTime = 0LL;
+    long long endTime = 0LL;
+    long long totalDelta = 0LL;
+    long long average = 0LL;
+
+    ByteArrayInputStream bis( buffer, bufferSize );
+    std::vector<long long> deltaTs;
+
+    for( int i = 0; i < totalRuns; ++i ) {
+        startTime = Date::getCurrentTimeMilliseconds();
+
+        // Time a large read
+        bis.read( recvBuffer, bufferSize );
+
+        endTime = Date::getCurrentTimeMilliseconds();
+
+        // Save the result
+        deltaTs.push_back( endTime - startTime );
+
+        bis.reset();
+    }
+
+    // Sum the Time Deltas for all runs.
+    for( int j = 0; j < totalRuns; ++j ) {
+        totalDelta += deltaTs[j];
+    }
+
+    average = totalDelta / totalRuns;
+
+    std::cout << "Averqage time of competion was: "
+              << average << " Milliseconds." << std::endl;
+
+    delete [] buffer;
+    delete [] recvBuffer;
+
+    std::cout << "-----------------------------------------------------\n";
+    std::cout << "Finished with the example\n";
+    std::cout << "=====================================================\n";
+}
+
+// END SNIPPET: demo