Package java.util

Examples of java.util.Random$RandomDoublesSpliterator


            swap(array, i, r.nextInt(limit));
        }
    }

    public static void shuffle(final int[] array) {
        final Random r = new Random();
        final int limit = array.length;
        for(int i = 0; i < limit; ++i) {
            swap(array, i, r.nextInt(limit));
        }
    }
View Full Code Here


            swap(array, i, r.nextInt(limit));
        }
    }

    public static void shuffle(final Object[] array, final long seed) {
        final Random r = new Random(seed);
        final int limit = array.length;
        for(int i = 0; i < limit; ++i) {
            swap(array, i, r.nextInt(limit));
        }
    }
View Full Code Here

    TableOrTreeSWT table = tv.getTableOrTreeSWT();
    try {
      //System.out.println(gc.getForeground().getRGB().toString());
      //System.out.println("paintItem " + gc.getClipping());
      if (TableViewSWTImpl.DEBUG_CELL_CHANGES) {
        Random random = new Random(SystemTime.getCurrentTime() / 500);
        gc.setBackground(ColorCache.getColor(gc.getDevice(),
            210 + random.nextInt(45), 210 + random.nextInt(45),
            210 + random.nextInt(45)));
        gc.fillRectangle(gc.getClipping());
      }

      if (item == null || item.isDisposed()) {
        return;
View Full Code Here

        final TextProgressBar bar = new TextProgressBar("test", 100) {
            protected void show() {
                System.out.println(getInfo());
            }
        };
        final Random rand = new Random(2390814071209731L);
        for(int i = 0; i < 100; i++) {
            Thread.sleep(rand.nextInt(3000));
            bar.inc();
        }
        bar.finish();
        System.err.println(bar.getInfo());
    }
View Full Code Here

            m_protocol = protocol;
            m_requestType = reqtype;
            m_responseTypes = rsptypes;
            m_verbose = verbose;
            m_loops = loops;
            m_random = new Random(5);
            m_halfRangeFraction = fraction * 0.5;
            m_halfRangeFractionRoot = Math.sqrt(fraction) * 0.5;
            m_utcZone = TimeZone.getTimeZone("UTC");
            Calendar calendar = new GregorianCalendar(m_utcZone);
            m_format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
View Full Code Here

  String[]  args )
  {
    SHA1Hasher  s1 = new SHA1Hasher();
    SHA1Simple  s2 = new SHA1Simple();
   
    Random  r = new Random();
   
    for (int i=0;i<10000;i++){
     
      int  len = r.nextInt(32);
     
      byte[]  x = new byte[len];
     
      r.nextBytes( x );
     
      byte[]  h1 = s1.calculateHash( x );
      byte[]  h2 = s2.calculateHash( x );
     
      if ( Arrays.equals( h1, h2)){
View Full Code Here

    }

    public void testRand1000() throws IOException {
        FastMultiByteArrayOutputStream out = new FastMultiByteArrayOutputStream(4096);
        DataOutputStream data = new DataOutputStream(out);
        Random rand = new Random(22222);
        for(int times = 0; times < 3; times++) {
            for(int i = 0; i < 1000; i++) {
                data.writeInt(rand.nextInt());
            }
            probe(out.toByteArray_clear());
        }
    }
View Full Code Here

    }

    public void testRand10000() throws IOException {
        FastMultiByteArrayOutputStream out = new FastMultiByteArrayOutputStream(4096);
        DataOutputStream data = new DataOutputStream(out);
        Random rand = new Random(44444);
        for(int times = 0; times < 3; times++) {
            for(int i = 0; i < 10000; i++) {
                data.writeInt(rand.nextInt());
            }
            probe(out.toByteArray_clear());
        }
    }
View Full Code Here

    }

    public void testRandGaussian10000() throws IOException {
        FastMultiByteArrayOutputStream out = new FastMultiByteArrayOutputStream(4096);
        DataOutputStream data = new DataOutputStream(out);
        Random rand = new Random(3333);
        for(int times = 0; times < 3; times++) {
            for(int i = 0; i < 10000; i++) {
                data.writeDouble(rand.nextGaussian());
            }
            probe(out.toByteArray_clear());
        }
    }
View Full Code Here

  private static final int TEST_SPEED_FACTOR = 1; // use larger numbers for less tests

  public static void main(String[] args)
  {
   
    Random rnd = new Random();

    SHA1Old oldsha = new SHA1Old();
    SHA1 newsha = new SHA1();

    ByteBuffer dBuffer = ByteBuffer.allocateDirect(BUFF_MAX_SIZE);
    ByteBuffer hBuffer = ByteBuffer.allocate(BUFF_MAX_SIZE);

    for (int i = 0; i < BUFF_MAX_SIZE; i++)
    {
      byte b = (byte) (rnd.nextInt()&0xFF);
      dBuffer.put(b);
    }
   
    dBuffer.rewind();
    hBuffer.put(dBuffer);
    hBuffer.rewind();
    dBuffer.rewind();
   

    // allow time for setting thread to high-priority
    try
    {
      System.out.println("Setting high thread priority to decrease test jitter");
      Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
      Thread.sleep(2000);
    } catch (Exception ignore)
    {
    }

    for (int t = 0; t < TESTS.length; t++)
    {

      int buffsize = TESTS[t] * 1024;

      dBuffer.position(0);
      dBuffer.limit(buffsize);
      hBuffer.position(0);
      hBuffer.limit(buffsize);

     
      int loops = LOOPS[t]/TEST_SPEED_FACTOR;

      String info = " [" + buffsize / 1024 + "KB, " + loops + "x] = ";

      double totalMBytes = ((double) buffsize / (1024 * 1024)) * loops;

     
      long time;
      double speed;

     
      System.out.println("direct:");
     
      System.out.print("Old SHA1");
      time = System.currentTimeMillis();
      for (int i = 0; i < loops; i++)
      {
        oldsha.reset();
        oldsha.digest(dBuffer);
      }
      time = System.currentTimeMillis() - time;
      speed = totalMBytes / (time / (double)1024);
      System.out.println(info + time + " ms @ " + speed + " MiB/s");

     
      System.out.print("New SHA1 ");
      time = System.currentTimeMillis();
      for (int i = 0; i < loops; i++)
      {
        newsha.reset();
        newsha.digest(dBuffer);
      }
      time = System.currentTimeMillis() - time;
      speed = totalMBytes / (time / (double)1024);
      System.out.println(info + time + " ms @ " + speed + " MiB/s");

      System.out.println("heap:");
     
      System.out.print("Old SHA1");
      time = System.currentTimeMillis();
      for (int i = 0; i < loops; i++)
      {
        oldsha.reset();
        oldsha.digest(hBuffer);
      }
      time = System.currentTimeMillis() - time;
      speed = totalMBytes / (time / (double)1024);
      System.out.println(info + time + " ms @ " + speed + " MiB/s");

     
      System.out.print("New SHA1 ");
      time = System.currentTimeMillis();
      for (int i = 0; i < loops; i++)
      {
        newsha.reset();
        newsha.digest(hBuffer);
      }
      time = System.currentTimeMillis() - time;
      speed = totalMBytes / (time / (double)1024);
      System.out.println(info + time + " ms @ " + speed + " MiB/s");

      System.out.println();
    }
   
   
    System.out.println("performing randomized buffer windowing checks, this may take a while");
   
    byte[] oldd;
    byte[] newd;
    byte[] oldh;
    byte[] newh;
   
    int size;
    int offset;
   
    ByteBuffer dview;
    ByteBuffer hview;
   
    for(int i=0;i<LOOPS[1]/TEST_SPEED_FACTOR;i++)
    {
      size = rnd.nextInt(BUFF_MAX_SIZE);
      offset = rnd.nextInt(BUFF_MAX_SIZE-size-1);
     
      hBuffer.limit(offset+size);
      hBuffer.position(offset);
      dBuffer.limit(offset+size);
      dBuffer.position(offset);
View Full Code Here

TOP

Related Classes of java.util.Random$RandomDoublesSpliterator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.