Tegra optimized cvRound; perf test for cvRound; fixed perf test for stitching
authorAndrey Kamaev <no@email>
Thu, 29 Sep 2011 12:11:18 +0000 (12:11 +0000)
committerAndrey Kamaev <no@email>
Thu, 29 Sep 2011 12:11:18 +0000 (12:11 +0000)
modules/core/include/opencv2/core/types_c.h
modules/core/perf/perf_core_arithm.cpp
modules/stitching/perf/perf_stich.cpp

index 68164fa..11dbabf 100644 (file)
@@ -259,6 +259,10 @@ enum {
 *                             Common macros and inline functions                         *
 \****************************************************************************************/
 
+#ifdef HAVE_TEGRA_OPTIMIZATION
+# include "tegra_round.hpp"
+#endif
+
 #define CV_PI   3.1415926535897932384626433832795
 #define CV_LOG2 0.69314718055994530941723212145818
 
@@ -300,7 +304,11 @@ CV_INLINE  int  cvRound( double value )
     }
     return t;
 #elif defined HAVE_LRINT || defined CV_ICC || defined __GNUC__
+# ifdef HAVE_TEGRA_OPTIMIZATION
+    TEGRA_ROUND(value);
+# else
     return (int)lrint(value);
+# endif
 #else
     // while this is not IEEE754-compliant rounding, it's usually a good enough approximation
     return (int)(value + (value >= 0 ? 0.5 : -0.5));
index 83d8d1e..7e48ca7 100644 (file)
@@ -62,3 +62,16 @@ PERF_TEST_P__CORE_ARITHM_SCALAR(subtract, TYPICAL_MATS_CORE_ARITHM)
 PERF_TEST_P__CORE_ARITHM_SCALAR(absdiff, TYPICAL_MATS_CORE_ARITHM)
 
 
+PERF_TEST(convert, cvRound)
+{
+    double number = theRNG().uniform(-100, 100);
+
+    int result = 0;
+
+    TEST_CYCLE(1000)
+    {
+        for (int i = 0; i < 500000; ++i)
+            result += cvRound(number);
+    }
+}
+
index 085d397..5b65c89 100644 (file)
@@ -19,12 +19,18 @@ PERF_TEST( stitch3, a123 )
     imgs.push_back( imread( getDataPath("stitching/a2.jpg") ) );\r
     imgs.push_back( imread( getDataPath("stitching/a3.jpg") ) );\r
 \r
-    Stitcher stitcher = Stitcher::createDefault();\r
     Stitcher::Status status;\r
 \r
     declare.time(30 * 20);\r
 \r
-    TEST_CYCLE(20) { status = stitcher.stitch(imgs, pano); }\r
+    while(next())\r
+    {\r
+        Stitcher stitcher = Stitcher::createDefault();\r
+\r
+        startTimer();\r
+        status = stitcher.stitch(imgs, pano);\r
+        stopTimer();\r
+    }\r
 }\r
 \r
 PERF_TEST( stitch2, b12 )\r
@@ -35,10 +41,16 @@ PERF_TEST( stitch2, b12 )
     imgs.push_back( imread( getDataPath("stitching/b1.jpg") ) );\r
     imgs.push_back( imread( getDataPath("stitching/b2.jpg") ) );\r
 \r
-    Stitcher stitcher = Stitcher::createDefault();\r
     Stitcher::Status status;\r
 \r
     declare.time(30 * 20);\r
 \r
-    TEST_CYCLE(20) { status = stitcher.stitch(imgs, pano); }\r
+    while(next())\r
+    {\r
+        Stitcher stitcher = Stitcher::createDefault();\r
+\r
+        startTimer();\r
+        status = stitcher.stitch(imgs, pano);\r
+        stopTimer();\r
+    }\r
 }\r