You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datasketches.apache.org by le...@apache.org on 2021/09/26 01:37:40 UTC

[datasketches-java] 01/02: remove unused tests

This is an automated email from the ASF dual-hosted git repository.

leerho pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/datasketches-java.git

commit 8dc75a483ceb990c3ea43c1c6dbea2158d11a4d0
Author: Lee Rhodes <le...@users.noreply.github.com>
AuthorDate: Tue Sep 21 13:56:21 2021 -0700

    remove unused tests
---
 .../org/apache/datasketches/cpc/LzTzSpeedTest.java | 175 ---------------------
 .../datasketches/cpc/SpecialCBinariesTest.java     | 122 --------------
 2 files changed, 297 deletions(-)

diff --git a/src/test/java/org/apache/datasketches/cpc/LzTzSpeedTest.java b/src/test/java/org/apache/datasketches/cpc/LzTzSpeedTest.java
deleted file mode 100644
index 9936609..0000000
--- a/src/test/java/org/apache/datasketches/cpc/LzTzSpeedTest.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * 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.datasketches.cpc;
-
-import static org.apache.datasketches.Util.iGoldenU64;
-import static org.testng.Assert.assertEquals;
-
-import java.util.Random;
-
-/**
- * Experimentally verifies that the Java leading and trailing zeros uses
- * intrinsic CPU instructions instead of the documented code. The java built=in functions are much
- * faster than even choosing most probable bytes algorithms that were derived from C.
- *
- * <p>These tests are for experimental characterization testing only and are not enabled for
- * normal unit testing.
- *
- * @author Lee Rhodes
- */
-@SuppressWarnings("javadoc")
-public class LzTzSpeedTest {
-  static final byte[] byteTrailingZerosTable = new byte[256];
-  static final byte[] byteLeadingZerosTable = new byte[256];
-
-  private static void fillByteTrailingZerosTable() {
-    byteTrailingZerosTable[0] = 8;
-    for (int i = 1; i < 256; i++) {
-      byteTrailingZerosTable[i] = (byte) Integer.numberOfTrailingZeros(i);
-    }
-  }
-
-  private static void fillByteLeadingZerosTable() {
-    byteLeadingZerosTable[0] = 8;
-    for (int i = 1; i < 256; i++) {
-      byteLeadingZerosTable[i] = (byte) Integer.numberOfLeadingZeros(i << 24);
-    }
-  }
-
-  static int countLeadingZerosByByte(final long theInput) {
-    long tmp;
-    if ((tmp = theInput >>> 56) > 0) { return 0 + byteLeadingZerosTable[(int)tmp]; }
-    if ((tmp = theInput >>> 48) > 0) { return 8 + byteLeadingZerosTable[(int)tmp]; }
-    if ((tmp = theInput >>> 40) > 0) { return 16 + byteLeadingZerosTable[(int)tmp]; }
-    if ((tmp = theInput >>> 32) > 0) { return 24 + byteLeadingZerosTable[(int)tmp]; }
-    if ((tmp = theInput >>> 24) > 0) { return 32 + byteLeadingZerosTable[(int)tmp]; }
-    if ((tmp = theInput >>> 16) > 0) { return 40 + byteLeadingZerosTable[(int)tmp]; }
-    if ((tmp = theInput >>>  8) > 0) { return 48 + byteLeadingZerosTable[(int)tmp]; }
-    return 56 + byteLeadingZerosTable[(int) (theInput & 0XFFL)];
-  }
-
-  static int countTrailingZerosByByte(final long theInput) {
-    long tmp = theInput;
-    for (int j = 0; j < 8; j++) {
-      final int aByte = (int) (tmp & 0XFFL);
-      if (aByte != 0) { return (j << 3) + byteTrailingZerosTable[aByte]; }
-      tmp >>>= 8;
-    }
-    return 64;
-  }
-
-  //@Test
-  public void checkLeadingTrailingZerosByByte() {
-    for (int i = 0; i < 64; i++) {
-      long in = 1L << i;
-      assertEquals(countTrailingZerosByByte(in), Long.numberOfTrailingZeros(in));
-      assertEquals(countLeadingZerosByByte(in), Long.numberOfLeadingZeros(in));
-    }
-  }
-
-  //@Test
-  public void checkLeadingZerosByByteRandom() {
-    Random rand = new Random();
-    int n = 1 << 10;
-    long signBit = 1L << 63;
-    for (int i = 0; i < 64; i++) {
-      for (int j = 0; j < n; j++) {
-        long in = (rand.nextLong() | signBit) >>> i;
-        assertEquals(countLeadingZerosByByte(in), Long.numberOfLeadingZeros(in));
-      }
-    }
-  }
-
-  //@Test
-  public void checkLeadingZerosSpeed() {
-    long signBit = 1L << 63;
-    int n = 1 << 28;
-    for (int shift = 0; shift < 64; shift++) {
-      long sum1 = 0;
-      long tmp = 0;
-      long t0 = System.nanoTime();
-      for (int i = 0; i < n; i++) {
-        long in =((tmp += iGoldenU64) | signBit) >>> shift;
-        sum1 += countLeadingZerosByByte(in);
-      }
-      long t1 = System.nanoTime();
-      double byteTime = (double)(t1 - t0) / n;
-
-      long sum2 = 0;
-      tmp = 0;
-      long t2 = System.nanoTime();
-      for (int i = 0; i < n; i++) {
-        long in =((tmp += iGoldenU64) | signBit) >>> shift;
-        sum2 += Long.numberOfLeadingZeros(in);
-      }
-      long t3 = System.nanoTime();
-      double longTime = (double)(t3 - t2) / n;
-      assert sum1 == sum2;
-      println("shift: " + shift + ", byte: " + byteTime + ", long: " + longTime);
-    }
-  }
-
-  //@Test
-  public void checkTrailingZerosSpeed() {
-    long oneBit = 1L;
-    int n = 1 << 28;
-    for (int shift = 0; shift < 64; shift++) {
-      long sum1 = 0;
-      long tmp = 0;
-      long t0 = System.nanoTime();
-      for (int i = 0; i < n; i++) {
-        long in =((tmp += iGoldenU64) | oneBit) << shift;
-        sum1 += countTrailingZerosByByte(in);
-      }
-      long t1 = System.nanoTime();
-      double byteTime = (double)(t1 - t0) / n;
-
-      long sum2 = 0;
-      tmp = 0;
-      long t2 = System.nanoTime();
-      for (int i = 0; i < n; i++) {
-        long in =((tmp += iGoldenU64) | oneBit) << shift;
-        sum2 += Long.numberOfTrailingZeros(in);
-      }
-      long t3 = System.nanoTime();
-      double longTime = (double)(t3 - t2) / n;
-      assert sum1 == sum2;
-      println("shift: " + shift + ", byte: " + byteTime + ", long: " + longTime);
-    }
-  }
-
-  //@Test
-  public void printlnTest() {
-    println("PRINTING: " + this.getClass().getName());
-  }
-
-  /**
-   * @param s value to print
-   */
-  static void println(String s) {
-    //System.out.println(s); //disable here
-  }
-
-  static {
-    fillByteTrailingZerosTable();
-    fillByteLeadingZerosTable();
-  }
-
-}
diff --git a/src/test/java/org/apache/datasketches/cpc/SpecialCBinariesTest.java b/src/test/java/org/apache/datasketches/cpc/SpecialCBinariesTest.java
deleted file mode 100644
index 17e3582..0000000
--- a/src/test/java/org/apache/datasketches/cpc/SpecialCBinariesTest.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * 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.datasketches.cpc;
-
-import static org.apache.datasketches.Util.getResourceFile;
-import static org.testng.Assert.assertTrue;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.nio.ByteOrder;
-import java.nio.file.Files;
-
-import org.apache.datasketches.SketchesArgumentException;
-import org.apache.datasketches.memory.MapHandle;
-import org.apache.datasketches.memory.Memory;
-import org.apache.datasketches.memory.WritableMapHandle;
-import org.apache.datasketches.memory.WritableMemory;
-import org.testng.annotations.Test;
-
-/**
- * @author Lee Rhodes
- */
-@SuppressWarnings("javadoc")
-public class SpecialCBinariesTest {
-  static PrintStream ps = System.out;
-  static final String LS = System.getProperty("line.separator");
-
-  @Test
-  @SuppressWarnings("unused")
-  public void checkCpc10mBin() {
-    String fileName = "cpc-10m.sk";
-    File file = getResourceFile(fileName);
-    try (MapHandle mh = Memory.map(file)) {
-      Memory mem = mh.get();
-      try {
-        CpcSketch sk = CpcSketch.heapify(mem);
-      } catch (SketchesArgumentException e) {} // Image was truncated by 4 bytes
-    } catch (Exception e) {
-      e.printStackTrace();
-    }
-  }
-
-  //@Test
-  public void checkFranksString() {
-    String hex = "06011006001ACC938E000000010000000100000009000000"
-        + "C0284BC1E001763B471D75617B0770CC9488E8DEE445D88A9347E97778C4A83E010600000D010000";
-    int len = hex.length();
-    byte[] byteArr = new byte[len/2];
-    for (int i = 0; i < (len/2); i++) {
-      String subStr = hex.substring(2*i, (2*i) + 2);
-      byteArr[i] = (byte) (Integer.parseInt(subStr, 16) & 0XFF);
-    }
-    println(CpcSketch.toString(byteArr, true));
-    CpcSketch sk = CpcSketch.heapify(byteArr);
-    assertTrue(sk.validate());
-    println(sk.toString(true));
-    println("Est: " + sk.getEstimate());
-    try {
-      //byteArrToFile(byteArr, "FranksFile.sk");
-    } catch (Exception e) {
-      throw new RuntimeException(e);
-    }
-  }
-
-  static void byteArrToFile(byte[] byteArr, String fileName) throws Exception {
-    String userDir = System.getProperty("user.dir");
-    String fullPathName = userDir + "/src/test/resources/" + fileName;
-    File file = new File(fullPathName);
-    if (file.exists()) { Files.delete(file.toPath()); }
-    assertTrue(file.createNewFile());
-    assertTrue(file.setWritable(true, false));
-    assertTrue(file.isFile());
-
-    try (WritableMapHandle wmh
-        = WritableMemory.writableMap(file, 0, byteArr.length, ByteOrder.nativeOrder())) {
-      WritableMemory wmem = wmh.getWritable();
-      wmem.putByteArray(0, byteArr, 0, byteArr.length);
-      wmh.force();
-    } catch (IOException e) {
-      e.printStackTrace();
-    }
-  }
-
-  @Test
-  public void printlnTest() {
-    println("PRINTING: " + this.getClass().getName());
-  }
-
-  /**
-   * @param format the string to print
-   * @param args the arguments
-   */
-  static void printf(String format, Object... args) {
-    //ps.printf(format, args);
-  }
-
-  /**
-   * @param s value to print
-   */
-  static void println(String s) {
-    //ps.println(s); //disable here
-  }
-
-}

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org