package cn.estsh.i3plus.core.apiservice.websocket;

import cn.estsh.i3plus.pojo.base.codemaker.SnowflakeIdMaker;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang3.RandomStringUtils;

import java.util.Random;

/**
 * @Description :
 * @Reference :
 * @Author : Adair Peng
 * @CreateDate : 2018-11-22 15:02
 * @Modify:
 **/
public class TestMain {

    public static void main(String[] args) {
        System.out.println(RandomStringUtils.random(15, true, false));

//        StringEscapeUtils.escapeHtml();
        /*long workerIdBits = 5L;
        long maxWorkerId = -1L ^ (-1L << workerIdBits);
        System.out.println("5 --> "+maxWorkerId);

        workerIdBits = 6L;
        maxWorkerId = -1L ^ (-1L << workerIdBits);
        System.out.println("6 --> "+maxWorkerId);

        workerIdBits = 8L;
        maxWorkerId = -1L ^ (-1L << workerIdBits);
        System.out.println("8 --> " + maxWorkerId);*/

        int wId = new Random().nextInt(29) + 1;
        System.out.println("random id -> "+wId);
        SnowflakeIdMaker m = new SnowflakeIdMaker(wId,3);

        int i = 0;
        long id;
        int c = 0;

        long l1 = System.currentTimeMillis();
        while(i < 1000){
            if(m.nextId() < 0) {
                System.out.println("======="+m.nextId());
                c++;
            }else{
                //System.out.println(m.nextId());
            }
            i++;
        }
        System.out.println("耗时：" + (System.currentTimeMillis()-l1));
        System.out.println("====end====error:" + c);
    }
}
