Examples of Random


Examples of java.util.Random

        prep.execute();
    }

    private static String getString(int id) {
        StringBuilder buff = new StringBuilder();
        Random rnd = new Random(id);
        int len = rnd.nextInt(40);
        for (int i = 0; i < len; i++) {
            String s = "bcdfghklmnprstwz";
            char c = s.charAt(rnd.nextInt(s.length()));
            buff.append(i == 0 ? Character.toUpperCase(c) : c);
            s = "aeiou  ";

            buff.append(s.charAt(rnd.nextInt(s.length())));
        }
        return buff.toString();
    }
View Full Code Here

Examples of java.util.Random

        testRandom();
    }

    private void testRandom() {
        int len = getSize(1000, 10000);
        Random random = new Random(10);
        for (int i = 0; i < len; i++) {
            int l = random.nextInt(10);
            String[] sql = new String[l];
            StringBuilder buff = new StringBuilder();
            for (int j = 0; j < l; j++) {
                sql[j] = randomStatement(random);
                buff.append(sql[j]);
View Full Code Here

Examples of java.util.Random

        assertEquals(10, m.interleave(0, 3));
        assertEquals(10, m.interleave(new int[] { 0, 3 }));
        long v = Integer.MAX_VALUE | ((long) Integer.MAX_VALUE << 31L);
        assertEquals(v, m.interleave(Integer.MAX_VALUE, Integer.MAX_VALUE));
        assertEquals(v, m.interleave(new int[] { Integer.MAX_VALUE, Integer.MAX_VALUE }));
        Random random = new Random(1);
        for (int i = 0; i < 1000; i++) {
            int x = random.nextInt(Integer.MAX_VALUE), y = random.nextInt(Integer.MAX_VALUE);
            v = m.interleave(new int[] {x, y});
            long v2 = m.interleave(x, y);
            assertEquals(v, v2);
            int x1 = m.deinterleave(2, v, 0);
            int y1 = m.deinterleave(2, v, 1);
            assertEquals(x, x1);
            assertEquals(y, y1);
        }
        for (int i = 0; i < 1000; i++) {
            int x = random.nextInt(1000), y = random.nextInt(1000), z = random.nextInt(1000);
            MultiDimension tool = MultiDimension.getInstance();
            long xyz = tool.interleave(new int[] { x, y, z });
            assertEquals(x, tool.deinterleave(3, xyz, 0));
            assertEquals(y, tool.deinterleave(3, xyz, 1));
            assertEquals(z, tool.deinterleave(3, xyz, 2));
View Full Code Here

Examples of java.util.Random

        String sql = multi.generatePreparedQuery("TEST", "XY", new String[] { "X", "Y" });
        sql += " ORDER BY X, Y";
        PreparedStatement prepMulti = conn.prepareStatement(sql);
        long timeMulti = 0, timeRegular = 0;
        int timeMax = getSize(500, 2000);
        Random rand = new Random(1);
        for (int i = 0; timeMulti < timeMax; i++) {
            int size = rand.nextInt(max / 10);
            int minX = rand.nextInt(max - size);
            int minY = rand.nextInt(max - size);
            int maxX = minX + size, maxY = minY + size;
            time = System.currentTimeMillis();
            ResultSet rs1 = multi.getResult(prepMulti, new int[] { minX, minY }, new int[] { maxX, maxY });
            timeMulti += System.currentTimeMillis() - time;
            time = System.currentTimeMillis();
View Full Code Here

Examples of java.util.Random

        String sql = multi.generatePreparedQuery("TEST", "XYZ", new String[] { "X", "Y", "Z" });
        sql += " ORDER BY X, Y, Z";
        PreparedStatement prepMulti = conn.prepareStatement(sql);
        long timeMulti = 0, timeRegular = 0;
        int timeMax = getSize(500, 2000);
        Random rand = new Random(1);
        for (int i = 0; timeMulti < timeMax; i++) {
            int size = rand.nextInt(max / 10);
            int minX = rand.nextInt(max - size);
            int minY = rand.nextInt(max - size);
            int minZ = rand.nextInt(max - size);
            int maxX = minX + size, maxY = minY + size, maxZ = minZ + size;
            time = System.currentTimeMillis();
            ResultSet rs1 = multi.getResult(prepMulti, new int[] { minX, minY, minZ }, new int[] { maxX, maxY, maxZ });
            timeMulti += System.currentTimeMillis() - time;
            time = System.currentTimeMillis();
View Full Code Here

Examples of java.util.Random

    private static void runBenchmarkWithZipfDistributionLock(Status stat, ILock lock, FixedSegments pager, ConcurrentPluggableCache<Long, byte[]> cache, int capacity, int round, double percent, int scanLength, long[] dist) {
        boolean scanning = false;
        long scanCount = 0L;

        final Random rand = new Random();

        int scanned = 0, zipf = 0;
        long base = 0L;

        long mills1 = System.currentTimeMillis();
        long ops = 0L;
        long miss = 0L;

        long totalExecInterval = 0L, totalDurationHold = 0L;
        long prelock = System.currentTimeMillis();

        final int limit = round - 1;
        for(int nth = 0, i = 0; !_stop; nth = (nth >= limit) ? 0 : nth + 1, i++) {
            final long key;
            if(scanning || scanLength != 0 && (i == scanLength && rand.nextDouble() < percent)) {
                if(++scanCount <= scanLength) {
                    if(!scanning) {
                        base = dist[nth];
                    }
                    key = base + scanCount;
View Full Code Here

Examples of java.util.Random

    private static void runBenchmarkWithZipfDistributionReadWriteLock(ReadWriteLock rwlock, Status stat, FixedSegments pager, ConcurrentPluggableCache<Long, byte[]> cache, int capacity, int round, double percent, int scanLength, long[] dist) {
        boolean scanning = false;
        long scanCount = 0L;

        final Random rand = new Random();

        int scanned = 0, zipf = 0;
        long base = 0L;

        long mills1 = System.currentTimeMillis();
        long ops = 0L;
        long miss = 0L;

        final Lock readLock = rwlock.readLock();
        final Lock writeLock = rwlock.writeLock();

        final int limit = round - 1;
        for(int nth = 0, i = 0; !_stop; nth = (nth >= limit) ? 0 : nth + 1, i++) {
            final long key;
            if(scanning || scanLength != 0 && (i == scanLength && rand.nextDouble() < percent)) {
                if(++scanCount <= scanLength) {
                    if(!scanning) {
                        base = dist[nth];
                    }
                    key = base + scanCount;
View Full Code Here

Examples of java.util.Random

    private static void runBenchmarkWithZipfDistributionSync(Status stat, FixedSegments pager, ConcurrentPluggableCache<Long, byte[]> cache, int capacity, int round, double percent, int scanLength, long[] dist) {
        boolean scanning = false;
        long scanCount = 0L;

        final Random rand = new Random();

        int scanned = 0, zipf = 0;
        long base = 0L;

        long mills1 = System.currentTimeMillis();
        long ops = 0L;
        long miss = 0L;

        final int limit = round - 1;
        for(int nth = 0, i = 0; !_stop; nth = (nth >= limit) ? 0 : nth + 1, i++) {
            final long key;
            if(scanning || scanLength != 0 && (i == scanLength && rand.nextDouble() < percent)) {
                if(++scanCount <= scanLength) {
                    if(!scanning) {
                        base = dist[nth];
                    }
                    key = base + scanCount;
View Full Code Here

Examples of java.util.Random

    private static void runBenchmarkWithZipfDistributionLongHashLock(Status stat, ILock lock, FixedSegments pager, LongHash<byte[]> hash, int capacity, int round, double percent, int scanLength, long[] dist) {
        boolean scanning = false;
        long scanCount = 0L;

        final Random rand = new Random();

        int scanned = 0, zipf = 0;
        long base = 0L;

        long mills1 = System.currentTimeMillis();
        long ops = 0L;
        long miss = 0L;

        final int limit = round - 1;
        for(int nth = 0, i = 0; !_stop; nth = (nth >= limit) ? 0 : nth + 1, i++) {
            final long key;
            if(scanning || scanLength != 0 && (i == scanLength && rand.nextDouble() < percent)) {
                if(++scanCount <= scanLength) {
                    if(!scanning) {
                        base = dist[nth];
                    }
                    key = base + scanCount;
View Full Code Here

Examples of java.util.Random

    private static void runBenchmarkWithZipfDistributionLongHashSync(Status stat, FixedSegments pager, LongHash<byte[]> hash, int capacity, int round, double percent, int scanLength, long[] dist) {
        boolean scanning = false;
        long scanCount = 0L;

        final Random rand = new Random();

        int scanned = 0, zipf = 0;
        long base = 0L;

        long mills1 = System.currentTimeMillis();
        long ops = 0L;
        long miss = 0L;

        final int limit = round - 1;
        for(int nth = 0, i = 0; !_stop; nth = (nth >= limit) ? 0 : nth + 1, i++) {
            final long key;
            if(scanning || scanLength != 0 && (i == scanLength && rand.nextDouble() < percent)) {
                if(++scanCount <= scanLength) {
                    if(!scanning) {
                        base = dist[nth];
                    }
                    key = base + scanCount;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.