pig-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dvrya...@apache.org
Subject svn commit: r1369247 - in /pig/trunk: CHANGES.txt build.xml test/org/apache/pig/test/TestInvoker.java test/org/apache/pig/test/TestInvokerSpeed.java test/unit-tests
Date Fri, 03 Aug 2012 23:08:32 GMT
Author: dvryaboy
Date: Fri Aug  3 23:08:31 2012
New Revision: 1369247

URL: http://svn.apache.org/viewvc?rev=1369247&view=rev
Log:
PIG-2569: Fix org.apache.pig.test.TestInvoker.testSpeed

Added:
    pig/trunk/test/org/apache/pig/test/TestInvokerSpeed.java
Modified:
    pig/trunk/CHANGES.txt
    pig/trunk/build.xml
    pig/trunk/test/org/apache/pig/test/TestInvoker.java
    pig/trunk/test/unit-tests

Modified: pig/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/pig/trunk/CHANGES.txt?rev=1369247&r1=1369246&r2=1369247&view=diff
==============================================================================
--- pig/trunk/CHANGES.txt (original)
+++ pig/trunk/CHANGES.txt Fri Aug  3 23:08:31 2012
@@ -24,6 +24,8 @@ INCOMPATIBLE CHANGES
 
 IMPROVEMENTS
 
+PIG-2569: Fix org.apache.pig.test.TestInvoker.testSpeed (aklochkov via dvryaboy)
+
 PIG-2858: Improve PlanHelper to allow finding any PhysicalOperator in a plan (dvryaboy)
 
 PIG-2854: AvroStorage doesn't work with Avro 1.7.1 (cheolsoo via sms)

Modified: pig/trunk/build.xml
URL: http://svn.apache.org/viewvc/pig/trunk/build.xml?rev=1369247&r1=1369246&r2=1369247&view=diff
==============================================================================
--- pig/trunk/build.xml (original)
+++ pig/trunk/build.xml Fri Aug  3 23:08:31 2012
@@ -835,6 +835,7 @@
                        <excludesfile name="${test.exclude.file.23}" if="isHadoop23" />
                     </patternset>
                     <exclude name="**/${exclude.testcase}.java" if="exclude.testcase"
/>
+                    <exclude name="**/TestInvokerSpeed.java" if="clover.enabled"/>
                 </fileset>
             </batchtest>
             <batchtest fork="yes" todir="${test.log.dir}" if="testcase">

Modified: pig/trunk/test/org/apache/pig/test/TestInvoker.java
URL: http://svn.apache.org/viewvc/pig/trunk/test/org/apache/pig/test/TestInvoker.java?rev=1369247&r1=1369246&r2=1369247&view=diff
==============================================================================
--- pig/trunk/test/org/apache/pig/test/TestInvoker.java (original)
+++ pig/trunk/test/org/apache/pig/test/TestInvoker.java Fri Aug  3 23:08:31 2012
@@ -19,11 +19,9 @@
 package org.apache.pig.test;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
 
 import java.io.IOException;
 
-import org.apache.pig.EvalFunc;
 import org.apache.pig.builtin.InvokeForDouble;
 import org.apache.pig.builtin.InvokeForFloat;
 import org.apache.pig.builtin.InvokeForInt;
@@ -165,35 +163,4 @@ public class TestInvoker {
       }
       return bag;
     }
-
-    @Test
-    public void testSpeed() throws IOException, SecurityException, ClassNotFoundException,
NoSuchMethodException {
-        EvalFunc<Double> log = new Log();
-        Tuple tup = tf_.newTuple(1);
-        long start = System.currentTimeMillis();
-        for (int i=0; i < 1000000; i++) {
-            tup.set(0, (double) i);
-            log.exec(tup);
-        }
-        long staticSpeed = (System.currentTimeMillis()-start);
-        start = System.currentTimeMillis();
-        log = new InvokeForDouble("java.lang.Math.log", "Double", "static");
-        for (int i=0; i < 1000000; i++) {
-            tup.set(0, (double) i);
-            log.exec(tup);
-        }
-        long dynamicSpeed = System.currentTimeMillis()-start;
-        System.err.println("Dynamic to static ratio: "+((float) dynamicSpeed)/staticSpeed);
-        assertTrue( ((float) dynamicSpeed)/staticSpeed < 5);
-    }
-    
-    private class Log extends EvalFunc<Double> {
-
-        @Override
-        public Double exec(Tuple input) throws IOException {
-            Double d = (Double) input.get(0);
-            return Math.log(d);
-        }
-        
-    }
-}
+}
\ No newline at end of file

Added: pig/trunk/test/org/apache/pig/test/TestInvokerSpeed.java
URL: http://svn.apache.org/viewvc/pig/trunk/test/org/apache/pig/test/TestInvokerSpeed.java?rev=1369247&view=auto
==============================================================================
--- pig/trunk/test/org/apache/pig/test/TestInvokerSpeed.java (added)
+++ pig/trunk/test/org/apache/pig/test/TestInvokerSpeed.java Fri Aug  3 23:08:31 2012
@@ -0,0 +1,68 @@
+/*
+ * 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.
+ */
+
+package org.apache.pig.test;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+
+import org.apache.pig.EvalFunc;
+import org.apache.pig.builtin.InvokeForDouble;
+import org.apache.pig.data.Tuple;
+import org.apache.pig.data.TupleFactory;
+import org.junit.Test;
+
+/** 
+ * Tests {@link Invoker} speed comparing to raw calculation.
+ */
+public class TestInvokerSpeed {
+
+    private final TupleFactory tf_ = TupleFactory.getInstance();
+
+    @Test
+    public void testSpeed() throws IOException, SecurityException, ClassNotFoundException,
NoSuchMethodException {
+        EvalFunc<Double> log = new Log();
+        Tuple tup = tf_.newTuple(1);
+        long start = System.currentTimeMillis();
+        for (int i=0; i < 1000000; i++) {
+            tup.set(0, (double) i);
+            log.exec(tup);
+        }
+        long staticSpeed = (System.currentTimeMillis()-start);
+        start = System.currentTimeMillis();
+        log = new InvokeForDouble("java.lang.Math.log", "Double", "static");
+        for (int i=0; i < 1000000; i++) {
+            tup.set(0, (double) i);
+            log.exec(tup);
+        }
+        long dynamicSpeed = System.currentTimeMillis()-start;
+        System.err.println("Dynamic to static ratio: "+((float) dynamicSpeed)/staticSpeed);
+        assertTrue( ((float) dynamicSpeed)/staticSpeed < 5);
+    }
+    
+    private class Log extends EvalFunc<Double> {
+
+        @Override
+        public Double exec(Tuple input) throws IOException {
+            Double d = (Double) input.get(0);
+            return Math.log(d);
+        }
+        
+    }
+}

Modified: pig/trunk/test/unit-tests
URL: http://svn.apache.org/viewvc/pig/trunk/test/unit-tests?rev=1369247&r1=1369246&r2=1369247&view=diff
==============================================================================
--- pig/trunk/test/unit-tests (original)
+++ pig/trunk/test/unit-tests Fri Aug  3 23:08:31 2012
@@ -28,6 +28,7 @@
 **/TestGTOrEqual.java
 **/TestInstantiateFunc.java
 **/TestInvoker.java
+**/TestInvokerSpeed.java
 **/TestLessThan.java
 **/TestLoadFunc.java
 **/TestLocal2.java



Mime
View raw message