activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r927065 - in /activemq/activemq-cpp/trunk/activemq-cpp/src/test-benchmarks: Makefile.am decaf/io/BufferedInputStreamBenchmark.cpp decaf/io/BufferedInputStreamBenchmark.h testRegistry.cpp
Date Wed, 24 Mar 2010 14:10:36 GMT
Author: tabish
Date: Wed Mar 24 14:10:36 2010
New Revision: 927065

URL: http://svn.apache.org/viewvc?rev=927065&view=rev
Log:
Adds a benchmark test for the BufferedInputStream class.

Added:
    activemq/activemq-cpp/trunk/activemq-cpp/src/test-benchmarks/decaf/io/BufferedInputStreamBenchmark.cpp
  (with props)
    activemq/activemq-cpp/trunk/activemq-cpp/src/test-benchmarks/decaf/io/BufferedInputStreamBenchmark.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=927065&r1=927064&r2=927065&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 Wed Mar 24 14:10:36
2010
@@ -18,6 +18,7 @@
 cc_sources = \
     activemq/util/PrimitiveMapBenchmark.cpp \
     benchmark/PerformanceTimer.cpp \
+    decaf/io/BufferedInputStreamBenchmark.cpp \
     decaf/io/ByteArrayInputStreamBenchmark.cpp \
     decaf/io/ByteArrayOutputStreamBenchmark.cpp \
     decaf/io/DataInputStreamBenchmark.cpp \
@@ -36,6 +37,7 @@ h_sources = \
     activemq/util/PrimitiveMapBenchmark.h \
     benchmark/BenchmarkBase.h \
     benchmark/PerformanceTimer.h \
+    decaf/io/BufferedInputStreamBenchmark.h \
     decaf/io/ByteArrayInputStreamBenchmark.h \
     decaf/io/ByteArrayOutputStreamBenchmark.h \
     decaf/io/DataInputStreamBenchmark.h \

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/test-benchmarks/decaf/io/BufferedInputStreamBenchmark.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test-benchmarks/decaf/io/BufferedInputStreamBenchmark.cpp?rev=927065&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test-benchmarks/decaf/io/BufferedInputStreamBenchmark.cpp
(added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test-benchmarks/decaf/io/BufferedInputStreamBenchmark.cpp
Wed Mar 24 14:10:36 2010
@@ -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 "BufferedInputStreamBenchmark.h"
+
+using namespace decaf;
+using namespace decaf::io;
+
+////////////////////////////////////////////////////////////////////////////////
+const int BufferedInputStreamBenchmark::bufferSize = 200000;
+
+////////////////////////////////////////////////////////////////////////////////
+BufferedInputStreamBenchmark::BufferedInputStreamBenchmark() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+BufferedInputStreamBenchmark::~BufferedInputStreamBenchmark() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void BufferedInputStreamBenchmark::setUp() {
+
+    buffer = new unsigned char[bufferSize];
+    source.setByteArray( buffer, bufferSize );
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void BufferedInputStreamBenchmark::tearDown(){
+
+    delete [] buffer;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void BufferedInputStreamBenchmark::run(){
+
+    int numRuns = 25;
+
+    std::vector<unsigned char> bucket( bufferSize );
+    BufferedInputStream bis( &source );
+
+    for( int iy = 0; iy < numRuns; ++iy ){
+        BufferedInputStream local( &source );
+    }
+
+    for( int iy = 0; iy < numRuns; ++iy ){
+
+        for( int iz = 0; iz < bufferSize; ++iz ) {
+            bucket[iy] = (unsigned char)bis.read();
+        }
+        source.reset();
+    }
+
+    for( int iy = 0; iy < numRuns; ++iy ){
+        bis.read( &bucket[0], bufferSize, 0, bufferSize );
+        source.reset();
+    }
+
+}

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

Added: activemq/activemq-cpp/trunk/activemq-cpp/src/test-benchmarks/decaf/io/BufferedInputStreamBenchmark.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/src/test-benchmarks/decaf/io/BufferedInputStreamBenchmark.h?rev=927065&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/src/test-benchmarks/decaf/io/BufferedInputStreamBenchmark.h
(added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/src/test-benchmarks/decaf/io/BufferedInputStreamBenchmark.h
Wed Mar 24 14:10:36 2010
@@ -0,0 +1,52 @@
+/*
+ * 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_BUFFEREDINPUTSTREAMBENCHMARK_H_
+#define _DECAF_IO_BUFFEREDINPUTSTREAMBENCHMARK_H_
+
+#include <benchmark/BenchmarkBase.h>
+#include <decaf/io/BufferedInputStream.h>
+#include <decaf/io/ByteArrayInputStream.h>
+
+namespace decaf {
+namespace io {
+
+    class BufferedInputStreamBenchmark : public benchmark::BenchmarkBase<
+        BufferedInputStreamBenchmark, BufferedInputStream >
+    {
+    private:
+
+        static const int bufferSize;
+
+        unsigned char* buffer;
+        ByteArrayInputStream source;
+
+    public:
+
+        BufferedInputStreamBenchmark();
+
+        virtual ~BufferedInputStreamBenchmark();
+
+        virtual void setUp();
+        virtual void tearDown();
+        virtual void run();
+
+    };
+
+}}
+
+#endif /* _DECAF_IO_BUFFEREDINPUTSTREAMBENCHMARK_H_ */

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/src/test-benchmarks/decaf/io/BufferedInputStreamBenchmark.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=927065&r1=927064&r2=927065&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 Wed Mar
24 14:10:36 2010
@@ -36,6 +36,8 @@ CPPUNIT_TEST_SUITE_REGISTRATION( decaf::
 CPPUNIT_TEST_SUITE_REGISTRATION( decaf::io::ByteArrayOutputStreamBenchmark );
 #include <decaf/io/ByteArrayInputStreamBenchmark.h>
 CPPUNIT_TEST_SUITE_REGISTRATION( decaf::io::ByteArrayInputStreamBenchmark );
+#include <decaf/io/BufferedInputStreamBenchmark.h>
+CPPUNIT_TEST_SUITE_REGISTRATION( decaf::io::BufferedInputStreamBenchmark );
 #include <decaf/io/DataInputStreamBenchmark.h>
 CPPUNIT_TEST_SUITE_REGISTRATION( decaf::io::DataInputStreamBenchmark );
 #include <decaf/io/DataOutputStreamBenchmark.h>



Mime
View raw message