http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/00f5d4ee/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java
----------------------------------------------------------------------
diff --cc 
modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java
index 02c25c6,90c6cb6..9a0a117
--- 
a/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java
@@@ -1436,30 -1424,55 +1426,79 @@@ public final class GridTestUtils 
      }
  
      /**
+      * @param name Name.
+      * @param run Run.
+      */
+     public static void benchmark(@Nullable String name, @NotNull Runnable 
run) {
+         benchmark(name, 8000, 10000, run);
+     }
+ 
+     /**
+      * @param name Name.
+      * @param warmup Warmup.
+      * @param executionTime Time.
+      * @param run Run.
+      */
+     public static void benchmark(@Nullable String name, long warmup, long 
executionTime, @NotNull Runnable run) {
+         final AtomicBoolean stop = new AtomicBoolean();
+ 
+         class Stopper extends TimerTask {
+             @Override public void run() {
+                 stop.set(true);
+             }
+         }
+ 
+         new Timer(true).schedule(new Stopper(), warmup);
+ 
+         while (!stop.get())
+             run.run();
+ 
+         stop.set(false);
+ 
+         new Timer(true).schedule(new Stopper(), executionTime);
+ 
+         long startTime = System.currentTimeMillis();
+ 
+         int cnt = 0;
+ 
+         do {
+             run.run();
+ 
+             cnt++;
+         }
+         while (!stop.get());
+ 
+         double dur = (System.currentTimeMillis() - startTime) / 1000d;
+ 
+         System.out.printf("%s:\n operations:%d, duration=%fs, op/s=%d, 
latency=%fms\n", name, cnt, dur,
+             (long)(cnt / dur), dur / cnt);
+     }
+ 
+     /**
 +     * Prompt to execute garbage collector.
-      * {@code System.gc();} is not guaranteed to gerbade collection, this 
method try to fill memory to crowd out dead
++     * {@code System.gc();} is not guaranteed to garbage collection, this 
method try to fill memory to crowd out dead
 +     * objects.
 +     */
 +    public static void runGC() {
 +        System.gc();
 +
 +        ReferenceQueue queue = new ReferenceQueue();
 +
 +        List<SoftReference> refs = new ArrayList<>();
 +
 +        while (true) {
 +            byte[] bytes = new byte[128 * 1024];
 +
-             refs.add(new SoftReference<>(bytes, queue));
++            refs.add(new SoftReference(bytes, queue));
 +
 +            if (queue.poll() != null)
 +                break;
 +        }
 +
 +        System.gc();
 +    }
 +
 +    /**
       * @return Path to apache ignite.
       */
      public static String apacheIgniteTestPath() {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/00f5d4ee/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/00f5d4ee/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/00f5d4ee/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/00f5d4ee/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractQuerySelfTest.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/00f5d4ee/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheCrossCacheQuerySelfTest.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/00f5d4ee/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapAndSwapSelfTest.java
----------------------------------------------------------------------

Reply via email to