parent
d6de6a01cc
commit
3e016bd97f
@ -1,47 +1,18 @@
|
|||||||
package com.luoo.user.util;
|
package com.luoo.user.util;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.IntStream;
|
import java.util.stream.IntStream;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.springframework.util.StopWatch;
|
|
||||||
|
|
||||||
import com.apifan.common.random.RandomSource;
|
|
||||||
import com.apifan.common.random.entity.Poem;
|
|
||||||
|
|
||||||
public class NickNameUtilTest {
|
public class NickNameUtilTest {
|
||||||
int size = 4;
|
|
||||||
|
|
||||||
String[] content = new String[] { "~", "`", "@", "$", "%", "^", "&", "*", "+", "-", "|", ".", "<", ">" };
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void test() {
|
||||||
int total = 100000;
|
int total = 1000000;
|
||||||
System.out.println("total: " + total);
|
System.out.println("total: " + total);
|
||||||
StopWatch sw = new StopWatch();
|
IntStream.range(0, total).parallel().mapToObj(j -> NickNameUtil.getRandomNickName()).limit(10)
|
||||||
sw.start();
|
.forEach(System.out::println);
|
||||||
IntStream.range(0, total).parallel().mapToObj(j -> getRandomNickName()).limit(100).forEach(System.out::println);
|
long distinctNickName = IntStream.range(0, total).parallel().mapToObj(j -> NickNameUtil.getRandomNickName())
|
||||||
for (int i = 4; i < 5; i++) {
|
.distinct().count();
|
||||||
size = i;
|
System.out.println("length: " + 9 + " distinctCount: " + distinctNickName);
|
||||||
long distinctNickName = IntStream.range(0, total).parallel().mapToObj(j -> getRandomNickName()).distinct()
|
|
||||||
.count();
|
|
||||||
System.out.println("length: " + i + " distinctCount: " + distinctNickName);
|
|
||||||
}
|
|
||||||
sw.stop();
|
|
||||||
System.out.println(sw.prettyPrint());
|
|
||||||
|
|
||||||
Poem poem=RandomSource.languageSource().randomTangPoem();
|
|
||||||
System.out.println(poem.getAuthor());
|
|
||||||
String content=Arrays.stream(poem.getContent()).collect(Collectors.joining("\r\n"));
|
|
||||||
System.out.println(content);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRandomNickName() {
|
|
||||||
int index = RandomSource.numberSource().randomInt(0, content.length);
|
|
||||||
String character = content[index];
|
|
||||||
return "雀乐-" + RandomSource.personInfoSource().randomChineseNickName(4) + character
|
|
||||||
+ RandomSource.personInfoSource().randomChineseNickName(4);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in new issue