Return-Path: Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: (qmail 96105 invoked from network); 2 Jul 2007 17:50:44 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 2 Jul 2007 17:50:44 -0000 Received: (qmail 74515 invoked by uid 500); 2 Jul 2007 17:50:47 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 74478 invoked by uid 500); 2 Jul 2007 17:50:47 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 74456 invoked by uid 99); 2 Jul 2007 17:50:47 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 Jul 2007 10:50:47 -0700 X-ASF-Spam-Status: No, hits=-99.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 Jul 2007 10:50:43 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 91CBA1A981A; Mon, 2 Jul 2007 10:50:23 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r552550 - /activemq/activemq-cpp/trunk/src/decaf/src/examples/main.cpp Date: Mon, 02 Jul 2007 17:50:23 -0000 To: commits@activemq.apache.org From: tabish@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070702175023.91CBA1A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 #include #include +#include #include #include #include @@ -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 deltaTs; + std::vector 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";