Stepan Koltsov avatar Stepan Koltsov committed 0f45470

reified cast test

Comments (0)

Files changed (14)

src/java/org/jetbrains/jet/perf/iteratorList/Filter.java

 package org.jetbrains.jet.perf.iteratorList;
 
 import org.jetbrains.jet.perf.iteratorList.lib.CollectionUtils;
+import org.jetbrains.jet.perf.util.TestUtils;
 
 import java.util.List;
 
         long totalDuration = 0;
         int junk = 0;
         for (int i = 0; i < iterationCount; ++i) {
-            List<Integer> list = TestUtils.makeListWithInts(collectionSize, i);
+            List<Integer> list = IteratorListTestUtils.makeListWithInts(collectionSize, i);
             long start = System.currentTimeMillis();
-            List<Integer> r = CollectionUtils.collect(CollectionUtils.filterToIterator(list.iterator(), TestUtils.positiveF()));
+            List<Integer> r = CollectionUtils.collect(CollectionUtils.filterToIterator(list.iterator(), IteratorListTestUtils.positiveF()));
             totalDuration += System.currentTimeMillis() - start;
-            junk += TestUtils.sum(r);
+            junk += IteratorListTestUtils.sum(r);
         }
         long nsPerOp = totalDuration * 1000000 / (collectionSize > 0 ? collectionSize : 1) / iterationCount;
         System.out.println("iterator: " + nsPerOp + "; cs=" + collectionSize + "; ic=" + iterationCount + "; " + junk);
         long totalDuration = 0;
         int junk = 0;
         for (int i = 0; i < iterationCount; ++i) {
-            List<Integer> list = TestUtils.makeListWithInts(collectionSize, i);
+            List<Integer> list = IteratorListTestUtils.makeListWithInts(collectionSize, i);
             long start = System.currentTimeMillis();
-            List<Integer> r = CollectionUtils.filterToList(list, TestUtils.positiveF());
+            List<Integer> r = CollectionUtils.filterToList(list, IteratorListTestUtils.positiveF());
             totalDuration += System.currentTimeMillis() - start;
-            junk += TestUtils.sum(r);
+            junk += IteratorListTestUtils.sum(r);
         }
         long nsPerOp = totalDuration * 1000000 / (collectionSize > 0 ? collectionSize : 1) / iterationCount;
         System.out.println("list    : " + nsPerOp + "; cs=" + collectionSize + "; ic=" + iterationCount + "; " + junk);

src/java/org/jetbrains/jet/perf/iteratorList/IteratorListTestUtils.java

+package org.jetbrains.jet.perf.iteratorList;
+
+import org.jetbrains.jet.perf.iteratorList.lib.Function;
+import org.jetbrains.jet.perf.util.TestUtils;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Stepan Koltsov
+ */
+public class IteratorListTestUtils {
+
+    public static List<Integer> makeListWithInts(int count, int seed) {
+        List<Integer> r = new ArrayList<Integer>();
+        for (int i = 0; i < count; ++i) {
+            r.add(TestUtils.hash(i, seed));
+        }
+        return r;
+    }
+
+    public static int sum(List<Integer> list) {
+        int r = 0;
+        for (Integer i : list) {
+            r += i;
+        }
+        return r;
+    }
+
+    public static Function<Integer, Integer> plus1F() {
+        return new Function<Integer, Integer>() {
+            @Override
+            public Integer apply(Integer integer) {
+                return integer + 1;
+            }
+        };
+    }
+
+    public static Function<Integer, Boolean> positiveF() {
+        return new Function<Integer, Boolean>() {
+            @Override
+            public Boolean apply(Integer integer) {
+                return integer > 0;
+            }
+        };
+    }
+}

src/java/org/jetbrains/jet/perf/iteratorList/Map.java

 package org.jetbrains.jet.perf.iteratorList;
 
 import org.jetbrains.jet.perf.iteratorList.lib.CollectionUtils;
+import org.jetbrains.jet.perf.util.TestUtils;
 
 import java.util.List;
 
         long totalDuration = 0;
         int junk = 0;
         for (int i = 0; i < iterationCount; ++i) {
-            List<Integer> list = TestUtils.makeListWithInts(collectionSize, i);
+            List<Integer> list = IteratorListTestUtils.makeListWithInts(collectionSize, i);
             long start = System.currentTimeMillis();
-            List<Integer> r = CollectionUtils.collect(CollectionUtils.mapToIterator(list.iterator(), TestUtils.plus1F()));
+            List<Integer> r = CollectionUtils.collect(CollectionUtils.mapToIterator(list.iterator(), IteratorListTestUtils.plus1F()));
             totalDuration += System.currentTimeMillis() - start;
-            junk += TestUtils.sum(r);
+            junk += IteratorListTestUtils.sum(r);
         }
         long nsPerOp = totalDuration * 1000000 / (collectionSize > 0 ? collectionSize : 1) / iterationCount;
         System.out.println("iterator: " + nsPerOp + "; cs=" + collectionSize + "; ic=" + iterationCount + "; " + junk);
         long totalDuration = 0;
         int junk = 0;
         for (int i = 0; i < iterationCount; ++i) {
-            List<Integer> list = TestUtils.makeListWithInts(collectionSize, i);
+            List<Integer> list = IteratorListTestUtils.makeListWithInts(collectionSize, i);
             long start = System.currentTimeMillis();
-            List<Integer> r = CollectionUtils.mapToList(list, TestUtils.plus1F());
+            List<Integer> r = CollectionUtils.mapToList(list, IteratorListTestUtils.plus1F());
             totalDuration += System.currentTimeMillis() - start;
-            junk += TestUtils.sum(r);
+            junk += IteratorListTestUtils.sum(r);
         }
         long nsPerOp = totalDuration * 1000000 / (collectionSize > 0 ? collectionSize : 1) / iterationCount;
         System.out.println("list    : " + nsPerOp + "; cs=" + collectionSize + "; ic=" + iterationCount + "; " + junk);

src/java/org/jetbrains/jet/perf/iteratorList/MapFilter.java

 package org.jetbrains.jet.perf.iteratorList;
 
 import org.jetbrains.jet.perf.iteratorList.lib.CollectionUtils;
+import org.jetbrains.jet.perf.util.TestUtils;
 
 import java.util.List;
 
         long totalDuration = 0;
         int junk = 0;
         for (int i = 0; i < iterationCount; ++i) {
-            List<Integer> list = TestUtils.makeListWithInts(collectionSize, i);
+            List<Integer> list = IteratorListTestUtils.makeListWithInts(collectionSize, i);
             long start = System.currentTimeMillis();
-            List<Integer> r = CollectionUtils.collect(CollectionUtils.filterToIterator(CollectionUtils.mapToIterator(list.iterator(), TestUtils.plus1F()), TestUtils.positiveF()));
+            List<Integer> r = CollectionUtils.collect(CollectionUtils.filterToIterator(CollectionUtils.mapToIterator(list.iterator(), IteratorListTestUtils.plus1F()), IteratorListTestUtils.positiveF()));
             totalDuration += System.currentTimeMillis() - start;
-            junk += TestUtils.sum(r);
+            junk += IteratorListTestUtils.sum(r);
         }
         long nsPerOp = totalDuration * 1000000 / (collectionSize > 0 ? collectionSize : 1) / iterationCount / 2;
         System.out.println("iterator: " + nsPerOp + "; cs=" + collectionSize + "; ic=" + iterationCount + "; " + junk);
         long totalDuration = 0;
         int junk = 0;
         for (int i = 0; i < iterationCount; ++i) {
-            List<Integer> list = TestUtils.makeListWithInts(collectionSize, i);
+            List<Integer> list = IteratorListTestUtils.makeListWithInts(collectionSize, i);
             long start = System.currentTimeMillis();
-            List<Integer> r = CollectionUtils.filterToList(CollectionUtils.mapToList(list, TestUtils.plus1F()), TestUtils.positiveF());
+            List<Integer> r = CollectionUtils.filterToList(CollectionUtils.mapToList(list, IteratorListTestUtils.plus1F()), IteratorListTestUtils.positiveF());
             totalDuration += System.currentTimeMillis() - start;
-            junk += TestUtils.sum(r);
+            junk += IteratorListTestUtils.sum(r);
         }
         long nsPerOp = totalDuration * 1000000 / (collectionSize > 0 ? collectionSize : 1) / iterationCount / 2;
         System.out.println("list    : " + nsPerOp + "; cs=" + collectionSize + "; ic=" + iterationCount + "; " + junk);

src/java/org/jetbrains/jet/perf/iteratorList/MapFilterMapFilter.java

 package org.jetbrains.jet.perf.iteratorList;
 
 import org.jetbrains.jet.perf.iteratorList.lib.CollectionUtils;
+import org.jetbrains.jet.perf.util.TestUtils;
 
 import java.util.List;
 
         long totalDuration = 0;
         int junk = 0;
         for (int i = 0; i < iterationCount; ++i) {
-            List<Integer> list = TestUtils.makeListWithInts(collectionSize, i);
+            List<Integer> list = IteratorListTestUtils.makeListWithInts(collectionSize, i);
             long start = System.currentTimeMillis();
             List<Integer> r = CollectionUtils.collect(
                     CollectionUtils.filterToIterator(
                             CollectionUtils.mapToIterator(
                                     CollectionUtils.filterToIterator(
-                                                CollectionUtils.mapToIterator(list.iterator(), TestUtils.plus1F()),
-                                                TestUtils.positiveF()),
-                                    TestUtils.plus1F()),
-                            TestUtils.positiveF())
+                                                CollectionUtils.mapToIterator(list.iterator(), IteratorListTestUtils.plus1F()),
+                                                IteratorListTestUtils.positiveF()),
+                                    IteratorListTestUtils.plus1F()),
+                            IteratorListTestUtils.positiveF())
             );
             totalDuration += System.currentTimeMillis() - start;
-            junk += TestUtils.sum(r);
+            junk += IteratorListTestUtils.sum(r);
         }
         long nsPerOp = totalDuration * 1000000000 / (collectionSize > 0 ? collectionSize : 1) / iterationCount / 4;
         System.out.println("iterator: " + nsPerOp + "; cs=" + collectionSize + "; ic=" + iterationCount + "; " + junk);
         long totalDuration = 0;
         int junk = 0;
         for (int i = 0; i < iterationCount; ++i) {
-            List<Integer> list = TestUtils.makeListWithInts(collectionSize, i);
+            List<Integer> list = IteratorListTestUtils.makeListWithInts(collectionSize, i);
             long start = System.currentTimeMillis();
             List<Integer> r =
                     CollectionUtils.filterToList(
                             CollectionUtils.mapToList(
                                     CollectionUtils.filterToList(
-                                            CollectionUtils.mapToList(list, TestUtils.plus1F()),
-                                    TestUtils.positiveF()),
-                            TestUtils.plus1F()),
-                    TestUtils.positiveF());
+                                            CollectionUtils.mapToList(list, IteratorListTestUtils.plus1F()),
+                                    IteratorListTestUtils.positiveF()),
+                            IteratorListTestUtils.plus1F()),
+                    IteratorListTestUtils.positiveF());
             totalDuration += System.currentTimeMillis() - start;
-            junk += TestUtils.sum(r);
+            junk += IteratorListTestUtils.sum(r);
         }
         long nsPerOp = totalDuration * 1000000000 / (collectionSize > 0 ? collectionSize : 1) / iterationCount / 4;
         System.out.println("list    : " + nsPerOp + "; cs=" + collectionSize + "; ic=" + iterationCount + "; " + junk);

src/java/org/jetbrains/jet/perf/iteratorList/MapOptimizedVsMapSimple.java

 package org.jetbrains.jet.perf.iteratorList;
 
 import org.jetbrains.jet.perf.iteratorList.lib.CollectionUtils;
+import org.jetbrains.jet.perf.util.TestUtils;
 
-import java.io.FileOutputStream;
+import java.io.File;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Random;
             runTestPairs(param[0], param[1], report);
         }
 
-        FileOutputStream os = new FileOutputStream(MapOptimizedVsMapSimple.class.getSimpleName() + ".txt");
-        try {
-            os.write(report.toString().getBytes("utf-8"));
-            os.close();
-        } finally {
-            os.close();
-        }
+        TestUtils.write(new File(MapOptimizedVsMapSimple.class.getSimpleName() + ".txt"), report);
 
         System.out.println("$ " + (iteration + 1));
     }
-    
+
     private static final Random random = new Random();
     
     private static java.util.Map<String, Long> mins = new HashMap<String, Long>();
         long totalDuration = 0;
         int junk = 0;
         for (int i = 0; i < iterationCount; ++i) {
-            List<Integer> list = TestUtils.makeListWithInts(collectionSize, i);
+            List<Integer> list = IteratorListTestUtils.makeListWithInts(collectionSize, i);
             long start = System.nanoTime();
-            List<Integer> r = CollectionUtils.mapToListSimple(list, TestUtils.plus1F());
+            List<Integer> r = CollectionUtils.mapToListSimple(list, IteratorListTestUtils.plus1F());
             totalDuration += System.nanoTime() - start;
-            junk += TestUtils.sum(r);
+            junk += IteratorListTestUtils.sum(r);
         }
         long psPerOp = totalDuration * 1000 / (collectionSize > 0 ? collectionSize : 1) / iterationCount;
         System.out.println("simple   : " + psPerOp + "ps; " + junk);
         long totalDuration = 0;
         int junk = 0;
         for (int i = 0; i < iterationCount; ++i) {
-            List<Integer> list = TestUtils.makeListWithInts(collectionSize, i);
+            List<Integer> list = IteratorListTestUtils.makeListWithInts(collectionSize, i);
             long start = System.nanoTime();
-            List<Integer> r = CollectionUtils.mapToList(list, TestUtils.plus1F());
+            List<Integer> r = CollectionUtils.mapToList(list, IteratorListTestUtils.plus1F());
             totalDuration += System.nanoTime() - start;
-            junk += TestUtils.sum(r);
+            junk += IteratorListTestUtils.sum(r);
         }
         long psPerOp = totalDuration * 1000 / (collectionSize > 0 ? collectionSize : 1) / iterationCount;
         System.out.println("optimized: " + psPerOp + "ps; " + junk);

src/java/org/jetbrains/jet/perf/iteratorList/TestUtils.java

-package org.jetbrains.jet.perf.iteratorList;
-
-import org.jetbrains.jet.perf.iteratorList.lib.Function;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Stepan Koltsov
- */
-public class TestUtils {
-    public static void printenv(Class<?> testClass) {
-        System.out.println(testClass.getName());
-        System.out.println(System.getProperty("java.version"));
-    }
-    
-    public static List<Integer> makeListWithInts(int count, int seed) {
-        List<Integer> r = new ArrayList<Integer>();
-        for (int i = 0; i < count; ++i) {
-            r.add(hash(i, seed));
-        }
-        return r;
-    }
-
-    public static int sum(List<Integer> list) {
-        int r = 0;
-        for (Integer i : list) {
-            r += i;
-        }
-        return r;
-    }
-
-    public static int hash(int i, int seed) {
-        return i * seed * 0x9e3779b1;
-    }
-
-    public static Function<Integer, Integer> plus1F() {
-        return new Function<Integer, Integer>() {
-            @Override
-            public Integer apply(Integer integer) {
-                return integer + 1;
-            }
-        };
-    }
-
-    public static Function<Integer, Boolean> positiveF() {
-        return new Function<Integer, Boolean>() {
-            @Override
-            public Boolean apply(Integer integer) {
-                return integer > 0;
-            }
-        };
-    }
-}

src/java/org/jetbrains/jet/perf/reified/BoxErased.java

+package org.jetbrains.jet.perf.reified;
+
+/**
+ * @author Stepan Koltsov
+ */
+public class BoxErased<T> {
+    private final boolean defined;
+    private final T value;
+
+    public BoxErased(boolean defined, T value) {
+        this.defined = defined;
+        this.value = value;
+    }
+
+    public boolean isDefined() {
+        return defined;
+    }
+
+    public T getValue() {
+        return value;
+    }
+}

src/java/org/jetbrains/jet/perf/reified/BoxReified.java

+package org.jetbrains.jet.perf.reified;
+
+/**
+ * @author Stepan Koltsov
+ */
+public class BoxReified<T> implements JetObject {
+    
+    private final boolean defined;
+    private final T value;
+    private final TypeInfoImpl typeInfo;
+
+    public BoxReified(boolean defined, T value, TypeInfoImpl typeInfo) {
+        this.defined = defined;
+        this.value = value;
+        this.typeInfo = typeInfo;
+    }
+
+    @Override
+    public TypeInfoImpl getTypeInfo() {
+        return typeInfo;
+    }
+
+    public boolean isDefined() {
+        return defined;
+    }
+
+    public T getValue() {
+        return value;
+    }
+}

src/java/org/jetbrains/jet/perf/reified/JetObject.java

+package org.jetbrains.jet.perf.reified;
+
+/**
+ * @author Stepan Koltsov
+ */
+public interface JetObject {
+
+    TypeInfoImpl getTypeInfo();
+
+}

src/java/org/jetbrains/jet/perf/reified/ReifiedVsErased.java

+package org.jetbrains.jet.perf.reified;
+
+import org.jetbrains.jet.perf.util.TestUtils;
+
+import java.io.File;
+import java.util.*;
+
+/**
+ * @author Stepan Koltsov
+ */
+public class ReifiedVsErased {
+    public static void main(String[] args) throws Exception {
+        TestUtils.printenv(ReifiedVsErased.class);
+        for (int i = 0; ; ++i) {
+            runTest(i);
+        }
+    }
+
+    private static void runTest(int iteration) throws Exception {
+        StringBuilder report = new StringBuilder();
+        System.out.println("iteration " + iteration);
+        report.append("iteration " + iteration + "\n");
+        report.append(new Date() + "\n");
+
+        int[][] params = {
+                {   50, 500000 },
+                {  500,  50000 },
+                { 5000,   5000 },
+        };
+
+
+        for (int[] param : params) {
+            runTestPairs(param[1], param[0], report);
+        }
+
+        report.append("$\n");
+        TestUtils.write(new File(ReifiedVsErased.class.getSimpleName() + ".txt"), report);
+    }
+    
+
+    private static final Map<String, Long> mins = new HashMap<String, Long>();
+
+    private static String key(int size, int count, Mode mode) {
+        return "s=" + size + "; c=" + count + "; mode=" + mode;
+    }
+
+
+    private static final Random random = new Random();
+
+    private static void runTestPairs(int size, int count, StringBuilder report) {
+        System.out.println("test pairs with s=" + size + "; c=" + count);
+        report.append("test pairs with s=" + size + "; c=" + count + "\n");
+        
+        int reifiedCount = 0;
+        int erasedCount = 0;
+        
+        while (reifiedCount < 2 || erasedCount < 2) {
+            long durationNsPerOp;
+            Mode mode;
+            if (random.nextBoolean()) {
+                mode = Mode.REIFIED;
+                durationNsPerOp = runTestWithReified(size, count);
+                ++reifiedCount;
+            } else {
+                mode = Mode.ERASED;
+                durationNsPerOp = runTestWithErased(size, count);
+                ++erasedCount;
+            }
+            String key = key(size, count, mode);
+            Long min = mins.get(key);
+            if (min == null || durationNsPerOp < min.longValue()) {
+                mins.put(key, durationNsPerOp);
+            }
+        }
+        
+        report.append("erased : " + String.format("%02d", mins.get(key(size, count, Mode.ERASED))) + "ns per op\n");
+        report.append("reified: " + String.format("%02d", mins.get(key(size, count, Mode.REIFIED))) + "ns per op\n");
+    }
+
+    private static final TypeInfoImpl integerTypeInfo = new TypeInfoImpl(false, Integer.class, new TypeInfoImpl[0]);
+    private static final TypeInfoImpl boxReifiedOfIntegerTypeInfo = new TypeInfoImpl(false, BoxReified.class, new TypeInfoImpl[] { integerTypeInfo });
+
+    
+    private static List<?> makeListOfReified(int size, int seed) {
+        List<Object> r = new ArrayList<Object>();
+        for (int i = 0; i < size; ++i) {
+            boolean defined = TestUtils.hash(i, seed) % 2 == 0;
+            r.add(new BoxReified<Integer>(defined, defined ? TestUtils.hash(i + 1, seed) : null, boxReifiedOfIntegerTypeInfo));
+        }
+        return r;
+    }
+
+    private static List<?> makeListOfErased(int size, int seed) {
+        List<Object> r = new ArrayList<Object>();
+        for (int i = 0; i < size; ++i) {
+            boolean defined = TestUtils.hash(i, seed) % 2 == 0;
+            r.add(new BoxErased<Integer>(defined, defined ? TestUtils.hash(i + 1, seed) : null));
+        }
+        return r;
+    }
+
+
+    private static long runTestWithReified(int size, int count) {
+        long totalDurationNs = 0;
+        int sum = 0;
+        for (int i = 0; i < count; ++i) {
+            List<?> list = makeListOfReified(size, i);
+            long start = System.nanoTime();
+            sum += Summer.sumDefinedWithReified(list);
+            totalDurationNs += System.nanoTime() - start;
+        }
+        return report(Mode.REIFIED, totalDurationNs, size, count, sum);
+    }
+    
+    private static long runTestWithErased(int size, int count) {
+        long totalDurationNs = 0;
+        int sum = 0;
+        for (int i = 0; i < count; ++i) {
+            List<?> list = makeListOfErased(size, i);
+            long start = System.nanoTime();
+            sum += Summer.sumDefinedWithErased(list);
+            totalDurationNs += System.nanoTime() - start;
+        }
+        return report(Mode.ERASED, totalDurationNs, size, count, sum);
+    }
+    
+    enum Mode {
+        REIFIED,
+        ERASED,
+    }
+    
+    private static long report(Mode mode, long totalDurationNs, int size, int count, int sum) {
+        StringBuilder tmp = new StringBuilder();
+        tmp.append(mode == Mode.ERASED ? "erased " : "reified");
+        tmp.append(": ");
+        long durationNsPerOp = totalDurationNs / size / count;
+        tmp.append(String.format("%02d", durationNsPerOp) + "ns per op; ");
+        tmp.append("s=" + size + "; c=" + count + "; " + sum);
+        System.out.println(tmp);
+        return durationNsPerOp;
+    }
+
+}

src/java/org/jetbrains/jet/perf/reified/Summer.java

+package org.jetbrains.jet.perf.reified;
+
+import java.util.List;
+
+/**
+ * @author Stepan Koltsov
+ */
+public class Summer {
+    
+    public static int sumDefinedWithErased(List<?> list) {
+        int sum = 0;
+        for (Object o : list) {
+            BoxErased<Integer> box = (BoxErased<Integer>) o;
+            if (box.isDefined()) {
+                sum += box.getValue();
+            }
+        }
+        return sum;
+    }
+    
+    private static final TypeInfoImpl integerTypeInfo = new TypeInfoImpl(false, Integer.class, new TypeInfoImpl[0]);
+    private static final TypeInfoImpl boxReifiedOfIntegerTypeInfo = new TypeInfoImpl(false, BoxReified.class, new TypeInfoImpl[] { integerTypeInfo });
+    
+    public static int sumDefinedWithReified(List<?> list) {
+        int sum = 0;
+        for (Object o : list) {
+            if (!boxReifiedOfIntegerTypeInfo.isInstance(o)) {
+                throw new ClassCastException();
+            }
+            BoxReified<Integer> box = (BoxReified<Integer>) o;
+            if (box.isDefined()) {
+                sum += box.getValue();
+            }
+        }
+        return sum;
+    }
+    
+}

src/java/org/jetbrains/jet/perf/reified/TypeInfoImpl.java

+package org.jetbrains.jet.perf.reified;
+
+/**
+ * @author Stepan Koltsov
+ */
+public class TypeInfoImpl {
+
+    private final boolean nullable;
+    private final Class<?> clazz;
+    private final TypeInfoImpl[] parameterTypes;
+
+    public TypeInfoImpl(boolean nullable, Class<?> clazz, TypeInfoImpl[] parameterTypes) {
+        this.nullable = nullable;
+        this.clazz = clazz;
+        this.parameterTypes = parameterTypes;
+    }
+
+    public boolean isInstance(Object obj) {
+        if (obj == null) {
+            return nullable;
+        }
+
+        if (obj instanceof JetObject) {
+            return ((JetObject) obj).getTypeInfo().isSubtypeOf(this);
+        }
+
+        return clazz.isInstance(obj);
+    }
+
+    public final boolean isSubtypeOf(TypeInfoImpl superType) {
+        if (nullable && !superType.nullable) {
+            return false;
+        }
+        if (!superType.clazz.isAssignableFrom(clazz)) {
+            return false;
+        }
+        if (superType.parameterTypes.length != parameterTypes.length) {
+            throw new IllegalArgumentException("inconsistent type info for the same class");
+        }
+        for (int i = 0; i < parameterTypes.length; i++) {
+            // TODO projections
+            if (!parameterTypes[i].isSubtypeOf(superType.parameterTypes[i])) {
+                return false;
+            }
+        }
+        return true;
+    }
+    
+}

src/java/org/jetbrains/jet/perf/util/TestUtils.java

+package org.jetbrains.jet.perf.util;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+/**
+ * @author Stepan Koltsov
+ */
+public class TestUtils {
+    public static void printenv(Class<?> testClass) {
+        System.out.println(testClass.getName());
+        System.out.println(System.getProperty("java.version"));
+    }
+
+    public static int hash(int i, int seed) {
+        return i * seed * 0x9e3779b1;
+    }
+
+    public static void write(File file, CharSequence string) throws IOException {
+        FileOutputStream os = new FileOutputStream(file);
+        try {
+            os.write(string.toString().getBytes("utf-8"));
+            os.close();
+        } finally {
+            os.close();
+        }
+    }
+}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.