activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r881490 - in /activemq/activemq-cpp/trunk/activemq-cpp/src/test-benchmarks: Makefile.am decaf/io/ByteArrayOutputStreamBenchmark.cpp decaf/io/ByteArrayOutputStreamBenchmark.h testRegistry.cpp
Date Tue, 17 Nov 2009 20:24:33 GMT
Author: tabish
Date: Tue Nov 17 20:24:32 2009
New Revision: 881490

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

Add benchmark test to use in performance tuning of Decaf classes.

Added:
    activemq/activemq-cpp/trunk/activemq-cpp/src/test-benchmarks/decaf/io/ByteArrayOutputStreamBenchmark.cpp
  (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/test-benchmarks/decaf/io/ByteArrayOutputStreamBenchmark.h
  (with props)
Modified:
    activemq/activemq-cpp/trunk/activemq-cpp/src/test-benchmarks/Makefile.am
    activemq/activemq-cpp/trunk/activemq-cpp/src/test-benchmarks/testRegistry.cpp

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test-benchmarks/Makefile.am
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test-benchmarks/Makefile.am?rev=881490&r1=881489&r2=881490&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test-benchmarks/Makefile.am (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test-benchmarks/Makefile.am Tue Nov 17 20:24:32
2009
@@ -19,6 +19,7 @@
     activemq/util/PrimitiveMapBenchmark.cpp \
     activemq/wireformat/openwire/utils/OpenWireStringSupportBenchmark.cpp \
     benchmark/PerformanceTimer.cpp \
+    decaf/io/ByteArrayOutputStreamBenchmark.cpp \
     decaf/io/DataInputStreamBenchmark.cpp \
     decaf/io/DataOutputStreamBenchmark.cpp \
     decaf/lang/BooleanBenchmark.cpp \
@@ -36,6 +37,7 @@
     activemq/wireformat/openwire/utils/OpenWireStringSupportBenchmark.h \
     benchmark/BenchmarkBase.h \
     benchmark/PerformanceTimer.h \
+    decaf/io/ByteArrayOutputStreamBenchmark.h \
     decaf/io/DataInputStreamBenchmark.h \
     decaf/io/DataOutputStreamBenchmark.h \
     decaf/lang/BooleanBenchmark.h \

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/test-benchmarks/decaf/io/ByteArrayOutputStreamBenchmark.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test-benchmarks/decaf/io/ByteArrayOutputStreamBenchmark.cpp?rev=881490&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test-benchmarks/decaf/io/ByteArrayOutputStreamBenchmark.cpp
(added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test-benchmarks/decaf/io/ByteArrayOutputStreamBenchmark.cpp
Tue Nov 17 20:24:32 2009
@@ -0,0 +1,72 @@
+/*
+ * 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.
+ */
+
+#include "ByteArrayOutputStreamBenchmark.h"
+
+using namespace decaf;
+using namespace decaf::io;
+
+////////////////////////////////////////////////////////////////////////////////
+ByteArrayOutputStreamBenchmark::ByteArrayOutputStreamBenchmark() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+ByteArrayOutputStreamBenchmark::~ByteArrayOutputStreamBenchmark() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void ByteArrayOutputStreamBenchmark::setUp() {
+
+    buffer = new unsigned char[bufferSize];
+
+    // init to full String Buffer
+    stlBuffer.reserve( bufferSize );
+    for( int ix = 0; ix < bufferSize - 1; ++ix ) {
+        buffer[ix] = 65;
+        stlBuffer.push_back( 65 );
+    }
+    buffer[bufferSize-1] = 0;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void ByteArrayOutputStreamBenchmark::tearDown(){
+
+    delete [] buffer;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void ByteArrayOutputStreamBenchmark::run(){
+
+    int numRuns = 100;
+
+    ByteArrayOutputStream bos;
+
+    for( int iy = 0; iy < numRuns; ++iy ){
+        bos.write( (char)65 );
+    }
+    bos.reset();
+
+    for( int iy = 0; iy < numRuns; ++iy ){
+        bos.write( buffer, 0, bufferSize );
+    }
+    bos.reset();
+
+    for( int iy = 0; iy < numRuns; ++iy ){
+        bos.write( stlBuffer );
+    }
+    bos.reset();
+}

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/test-benchmarks/decaf/io/ByteArrayOutputStreamBenchmark.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/test-benchmarks/decaf/io/ByteArrayOutputStreamBenchmark.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test-benchmarks/decaf/io/ByteArrayOutputStreamBenchmark.h?rev=881490&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test-benchmarks/decaf/io/ByteArrayOutputStreamBenchmark.h
(added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test-benchmarks/decaf/io/ByteArrayOutputStreamBenchmark.h
Tue Nov 17 20:24:32 2009
@@ -0,0 +1,50 @@
+/*
+ * 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.
+ */
+
+#ifndef _DECAF_IO_BYTEARRAYOUTPUTSTREAMBENCHMARK_H_
+#define _DECAF_IO_BYTEARRAYOUTPUTSTREAMBENCHMARK_H_
+
+#include <benchmark/BenchmarkBase.h>
+#include <decaf/io/ByteArrayOutputStream.h>
+
+namespace decaf {
+namespace io {
+
+    class ByteArrayOutputStreamBenchmark :
+    public benchmark::BenchmarkBase<
+        decaf::io::ByteArrayOutputStreamBenchmark, ByteArrayOutputStream >
+    {
+    private:
+
+        unsigned char* buffer;
+        std::vector<unsigned char> stlBuffer;
+        static const int bufferSize = 200000;
+
+    public:
+
+        ByteArrayOutputStreamBenchmark();
+        virtual ~ByteArrayOutputStreamBenchmark();
+
+        virtual void setUp();
+        virtual void tearDown();
+        virtual void run();
+
+    };
+
+}}
+
+#endif /* _DECAF_IO_BYTEARRAYOUTPUTSTREAMBENCHMARK_H_ */

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/test-benchmarks/decaf/io/ByteArrayOutputStreamBenchmark.h
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: activemq/activemq-cpp/trunk/activemq-cpp/src/test-benchmarks/testRegistry.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test-benchmarks/testRegistry.cpp?rev=881490&r1=881489&r2=881490&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test-benchmarks/testRegistry.cpp (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test-benchmarks/testRegistry.cpp Tue Nov
17 20:24:32 2009
@@ -35,6 +35,8 @@
 #include <decaf/util/MapBenchmark.h>
 CPPUNIT_TEST_SUITE_REGISTRATION( decaf::util::MapBenchmark );
 
+#include <decaf/io/ByteArrayOutputStreamBenchmark.h>
+CPPUNIT_TEST_SUITE_REGISTRATION( decaf::io::ByteArrayOutputStreamBenchmark );
 #include <decaf/io/DataInputStreamBenchmark.h>
 CPPUNIT_TEST_SUITE_REGISTRATION( decaf::io::DataInputStreamBenchmark );
 #include <decaf/io/DataOutputStreamBenchmark.h>



Mime
View raw message