activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r552550 - /activemq/activemq-cpp/trunk/src/decaf/src/examples/main.cpp
Date Mon, 02 Jul 2007 17:50:23 GMT
Author: tabish
Date: Mon Jul  2 10:50:22 2007
New Revision: 552550

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

Building Decaf lib

Modified:
    activemq/activemq-cpp/trunk/src/decaf/src/examples/main.cpp

Modified: 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=diff&rev=552550&r1=552549&r2=552550
==============================================================================
--- activemq/activemq-cpp/trunk/src/decaf/src/examples/main.cpp (original)
+++ activemq/activemq-cpp/trunk/src/decaf/src/examples/main.cpp Mon Jul  2 10:50:22 2007
@@ -23,6 +23,7 @@
 #include <decaf/util/concurrent/CountDownLatch.h>
 #include <decaf/util/Config.h>
 #include <decaf/io/ByteArrayInputStream.h>
+#include <decaf/io/ByteArrayOutputStream.h>
 #include <decaf/io/DataInputStream.h>
 #include <decaf/io/DataOutputStream.h>
 #include <decaf/util/Date.h>
@@ -36,10 +37,9 @@
 using namespace decaf::util::concurrent;
 using namespace std;
 
-int main(int argc DECAF_UNUSED, char* argv[] DECAF_UNUSED) {
+////////////////////////////////////////////////////////////////////////////////
+void testDataInputStream() {
 
-    std::cout << "=====================================================\n";
-    std::cout << "Starting the example:" << std::endl;
     std::cout << "-----------------------------------------------------\n";
     std::cout << "Testing performance of the DataInputStream:" << std::endl;
     std::cout << "-----------------------------------------------------\n";
@@ -69,7 +69,7 @@
         startTime = Date::getCurrentTimeMilliseconds();
 
         long long result = 0;
-        for( int iy = 0; iy < bufferSize / sizeof( result ); ++iy ){
+        for( size_t iy = 0; iy < bufferSize / sizeof( result ); ++iy ){
             result = dis.readLong();
         }
 
@@ -92,6 +92,88 @@
               << average << " Milliseconds." << std::endl;
 
     delete [] buffer;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void testDataOutputStream() {
+
+    std::cout << "-----------------------------------------------------\n";
+    std::cout << "Testing performance of the DataOutputStream:" << std::endl;
+    std::cout << "-----------------------------------------------------\n";
+
+    long long totalRuns = 2000LL;
+    long long startTime = 0LL;
+    long long endTime = 0LL;
+    long long totalDelta = 0LL;
+    long long average = 0LL;
+    std::vector<long long> deltaTs;
+    std::vector<unsigned char> outputBuffer;
+
+    std::string testString;
+    for( size_t i = 0; i < totalRuns * 10; ++i ) {
+        testString += 'a';
+    }
+
+    ByteArrayOutputStream bos( outputBuffer );
+    DataOutputStream dos( &bos );
+
+    for( int i = 0; i < totalRuns; ++i ) {
+
+        startTime = Date::getCurrentTimeMilliseconds();
+
+        for( int iy = 0; iy < totalRuns * 10; ++iy ){
+            dos.writeLong( 0xFF00FF00FF00FF00LL );
+        }
+        for( int iy = 0; iy < totalRuns * 10; ++iy ){
+            dos.writeInt( 312568 );
+        }
+        for( int iy = 0; iy < totalRuns * 10; ++iy ){
+            dos.writeShort( 12568 );
+        }
+        for( int iy = 0; iy < totalRuns * 10; ++iy ){
+            dos.writeUnsignedShort( 12568 );
+        }
+        for( int iy = 0; iy < totalRuns * 10; ++iy ){
+            dos.writeBoolean( true );
+        }
+        for( int iy = 0; iy < totalRuns * 10; ++iy ){
+            dos.writeDouble( 10.34235234 );
+        }
+        for( int iy = 0; iy < totalRuns; ++iy ){
+            dos.writeFloat( 32.4f );
+        }
+
+        dos.writeChars( testString );
+        dos.writeBytes( testString );
+        dos.writeUTF( testString );
+
+        endTime = Date::getCurrentTimeMilliseconds();
+
+        // Save the result
+        deltaTs.push_back( endTime - startTime );
+
+        outputBuffer.clear();
+    }
+
+    // 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;
+}
+
+int main(int argc DECAF_UNUSED, char* argv[] DECAF_UNUSED) {
+
+    std::cout << "=====================================================\n";
+    std::cout << "Starting the example:" << std::endl;
+    std::cout << "-----------------------------------------------------\n";
+
+    //testDataInputStream();
+    testDataOutputStream();
 
     std::cout << "-----------------------------------------------------\n";
     std::cout << "Finished with the example\n";



Mime
View raw message