Esempio n. 1
0
  public static void test() throws IOException {
    // do a sequence 1m of each of insert/read/update
    // inserts
    long LOOPCOUNT = 100 * 1000L;
    Random rand = new Random();
    long start = System.currentTimeMillis();
    BigDataStuff value = new BigDataStuff(0);
    for (long i = 0; i < LOOPCOUNT; i++) {
      long current = rand.nextInt(Highwatermark.get());
      value.x = current;
      value.y.setLength(0);
      value.y.append(current);
      TheSharedMap.put(i, value);
    }
    long now = System.currentTimeMillis();
    System.out.println(
        "Time taken to insert 100k entries " + ((now - start) / 1000.0) + " seconds");

    int count = 0;
    start = System.currentTimeMillis();
    for (long i = 0; i < LOOPCOUNT; i++) {
      long keyval = rand.nextInt(Highwatermark.get());
      count++;
      BigDataStuff stuff = TheSharedMap.get(keyval);
      if (stuff == null) {
        System.out.println("hit an empty at key " + keyval);
      }
    }
    now = System.currentTimeMillis();
    System.out.println(
        "Time taken to read "
            + count
            + " entries of 100k attempts "
            + ((now - start) / 1000.0)
            + " seconds");

    start = System.currentTimeMillis();
    count = 0;
    for (long i = 0; i < LOOPCOUNT; i++) {
      long keyval = rand.nextInt(Highwatermark.get());
      BigDataStuff stuff = TheSharedMap.get(keyval);
      if (stuff == null) {
        System.out.println("hit an empty at key " + keyval);
      } else {
        count++;
        stuff.x++;
        stuff.y.append('1');
        TheSharedMap.put(keyval, stuff);
      }
    }
    now = System.currentTimeMillis();
    System.out.println(
        "Time taken to read+update "
            + count
            + " entries of 100k attempts "
            + ((now - start) / 1000.0)
            + " seconds");
  }
Esempio n. 2
0
  public static void populate(int n) {
    AffinitySupport.setThreadId();

    long start = System.currentTimeMillis();
    BigDataStuff value = new BigDataStuff(0);
    for (long i = n; i < MAXSIZE; i += 4) {
      if (n == 0 && i % (10 * 1000 * 1000) == 0) {
        System.out.println(
            "Now inserted to "
                + i
                + " seconds since start = "
                + ((System.currentTimeMillis() - start) / 1000L));
      }
      value.x = i;
      value.y.setLength(0);
      value.y.append(i);
      TheSharedMap.put(i, value);
    }
  }