1 package com.romix.scala.collection.concurrent;
5 public class TestInstantiationSpeed {
6 private static final int COUNT = 1000000;
7 private static final int ITERATIONS = 10;
8 private static final int WARMUP = 20;
10 private long runIteration() {
11 final TrieMap<?, ?>[] maps = new TrieMap<?, ?>[COUNT];
12 final long start = System.nanoTime();
14 for (int i = 0; i < COUNT; ++i) {
15 maps[i] = TrieMap.empty();
18 final long stop = System.nanoTime();
23 public void testInstantiation() {
25 for (int i = 0; i < WARMUP; ++i) {
26 final long time = runIteration();
27 System.out.println(String.format("Warmup %s took %sns (%sns)", i, time, time / COUNT));
31 for (int i = 0; i < ITERATIONS; ++i) {
32 final long time = runIteration();
33 System.out.println(String.format("Iteration %s took %sns (%sns)", i, time, time / COUNT));
37 System.out.println("Instantiation cost " + acc / ITERATIONS / COUNT + "ns");