activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r554713 - in /activemq/activemq-cpp/trunk/src/test-benchmarks: Makefile.am activemq/util/MapBenchmark.cpp activemq/util/MapBenchmark.h activemq/util/SetBenchmark.cpp testRegistry.cpp
Date Mon, 09 Jul 2007 17:30:16 GMT
Author: tabish
Date: Mon Jul  9 10:30:14 2007
New Revision: 554713

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

Map Class Benchmark

Added:
    activemq/activemq-cpp/trunk/src/test-benchmarks/activemq/util/MapBenchmark.cpp
    activemq/activemq-cpp/trunk/src/test-benchmarks/activemq/util/MapBenchmark.h
Modified:
    activemq/activemq-cpp/trunk/src/test-benchmarks/Makefile.am
    activemq/activemq-cpp/trunk/src/test-benchmarks/activemq/util/SetBenchmark.cpp
    activemq/activemq-cpp/trunk/src/test-benchmarks/testRegistry.cpp

Modified: activemq/activemq-cpp/trunk/src/test-benchmarks/Makefile.am
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test-benchmarks/Makefile.am?view=diff&rev=554713&r1=554712&r2=554713
==============================================================================
--- activemq/activemq-cpp/trunk/src/test-benchmarks/Makefile.am (original)
+++ activemq/activemq-cpp/trunk/src/test-benchmarks/Makefile.am Mon Jul  9 10:30:14 2007
@@ -20,6 +20,7 @@
   activemq/util/PropertiesBenchmark.cpp \
   activemq/util/QueueBenchmark.cpp \
   activemq/util/SetBenchmark.cpp \
+  activemq/util/MapBenchmark.cpp \
   benchmark/PerformanceTimer.cpp \
   testRegistry.cpp \
   main.cpp
@@ -29,6 +30,7 @@
   activemq/util/PropertiesBenchmark.h \
   activemq/util/QueueBenchmark.h \
   activemq/util/SetBenchmark.h \
+  activemq/util/MapBenchmark.h \
   benchmark/BenchmarkBase.h \
   benchmark/PerformanceTimer.h
 

Added: activemq/activemq-cpp/trunk/src/test-benchmarks/activemq/util/MapBenchmark.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test-benchmarks/activemq/util/MapBenchmark.cpp?view=auto&rev=554713
==============================================================================
--- activemq/activemq-cpp/trunk/src/test-benchmarks/activemq/util/MapBenchmark.cpp (added)
+++ activemq/activemq-cpp/trunk/src/test-benchmarks/activemq/util/MapBenchmark.cpp Mon Jul
 9 10:30:14 2007
@@ -0,0 +1,75 @@
+/*
+ * 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 "MapBenchmark.h"
+#include <activemq/util/Integer.h>
+
+using namespace activemq;
+using namespace activemq::util;
+
+////////////////////////////////////////////////////////////////////////////////
+MapBenchmark::MapBenchmark() {
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void MapBenchmark::run() {
+
+    int numRuns = 500;
+    std::string test = "test";
+    std::string resultStr = "";
+    Map<std::string, std::string> stringCopy;
+    Map<int, int> intCopy;
+
+    for( int i = 0; i < numRuns; ++i ) {
+        stringMap.setValue( test + Integer::toString(i), test + Integer::toString(i) );
+        intMap.setValue( 100 + i, 100 + i );
+        stringMap.containsKey( test + Integer::toString(i) );
+        intMap.containsKey( 100 + i );
+        stringMap.containsValue( test + Integer::toString(i) );
+        intMap.containsValue( 100 + i );
+    }
+
+    for( int i = 0; i < numRuns; ++i ) {
+        stringMap.remove( test + Integer::toString(i) );
+        intMap.remove( 100 + i );
+        stringMap.containsKey( test + Integer::toString(i) );
+        intMap.containsKey( 100 + i );
+    }
+
+    for( int i = 0; i < numRuns; ++i ) {
+        stringMap.setValue( test + Integer::toString(i), test + Integer::toString(i) );
+        intMap.setValue( 100 + i, 100 + i );
+    }
+
+    std::vector<std::string> stringVec;
+    std::vector<int> intVec;
+
+    for( int i = 0; i < numRuns; ++i ) {
+        stringVec = stringMap.getKeys();
+        stringVec = stringMap.getValues();
+        intVec = intMap.getKeys();
+        intVec = intMap.getValues();
+    }
+
+    for( int i = 0; i < numRuns; ++i ) {
+        stringCopy.copy( stringMap );
+        stringCopy.clear();
+        intCopy.copy( intMap );
+        intCopy.clear();
+    }
+
+}

Added: activemq/activemq-cpp/trunk/src/test-benchmarks/activemq/util/MapBenchmark.h
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test-benchmarks/activemq/util/MapBenchmark.h?view=auto&rev=554713
==============================================================================
--- activemq/activemq-cpp/trunk/src/test-benchmarks/activemq/util/MapBenchmark.h (added)
+++ activemq/activemq-cpp/trunk/src/test-benchmarks/activemq/util/MapBenchmark.h Mon Jul 
9 10:30:14 2007
@@ -0,0 +1,46 @@
+/*
+ * 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 _ACTIVEMQ_UTIL_MAPBENCHMARK_H_
+#define _ACTIVEMQ_UTIL_MAPBENCHMARK_H_
+
+#include <benchmark/BenchmarkBase.h>
+#include <activemq/util/Map.h>
+
+namespace activemq{
+namespace util{
+
+    class MapBenchmark :
+        public benchmark::BenchmarkBase<
+            activemq::util::MapBenchmark, Map<int, int> >
+    {
+    private:
+
+        Map< std::string, std::string> stringMap;
+        Map<int, int> intMap;
+
+    public:
+
+        MapBenchmark();
+        virtual ~MapBenchmark() {}
+
+        virtual void run();
+    };
+
+}}
+
+#endif /*_ACTIVEMQ_UTIL_MAPBENCHMARK_H_*/

Modified: activemq/activemq-cpp/trunk/src/test-benchmarks/activemq/util/SetBenchmark.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test-benchmarks/activemq/util/SetBenchmark.cpp?view=diff&rev=554713&r1=554712&r2=554713
==============================================================================
--- activemq/activemq-cpp/trunk/src/test-benchmarks/activemq/util/SetBenchmark.cpp (original)
+++ activemq/activemq-cpp/trunk/src/test-benchmarks/activemq/util/SetBenchmark.cpp Mon Jul
 9 10:30:14 2007
@@ -61,12 +61,12 @@
         stringVec = stringSet.toArray();
         intVec = intSet.toArray();
     }
-
-    for( int i = 0; i < numRuns; ++i ) {
-        stringCopy.copy( stringSet );
-        stringCopy.clear();
-        intCopy.copy( intSet );
-        intCopy.clear();
-    }
+//
+//    for( int i = 0; i < numRuns; ++i ) {
+//        stringCopy.copy( stringSet );
+//        stringCopy.clear();
+//        intCopy.copy( intSet );
+//        intCopy.clear();
+//    }
 
 }

Modified: activemq/activemq-cpp/trunk/src/test-benchmarks/testRegistry.cpp
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test-benchmarks/testRegistry.cpp?view=diff&rev=554713&r1=554712&r2=554713
==============================================================================
--- activemq/activemq-cpp/trunk/src/test-benchmarks/testRegistry.cpp (original)
+++ activemq/activemq-cpp/trunk/src/test-benchmarks/testRegistry.cpp Mon Jul  9 10:30:14 2007
@@ -19,8 +19,10 @@
 #include <activemq/util/PropertiesBenchmark.h>
 #include <activemq/util/QueueBenchmark.h>
 #include <activemq/util/SetBenchmark.h>
+#include <activemq/util/MapBenchmark.h>
 
 CPPUNIT_TEST_SUITE_REGISTRATION( activemq::util::PrimitiveMapBenchmark );
 CPPUNIT_TEST_SUITE_REGISTRATION( activemq::util::PropertiesBenchmark );
 CPPUNIT_TEST_SUITE_REGISTRATION( activemq::util::QueueBenchmark );
 CPPUNIT_TEST_SUITE_REGISTRATION( activemq::util::SetBenchmark );
+CPPUNIT_TEST_SUITE_REGISTRATION( activemq::util::MapBenchmark );



Mime
View raw message