parent
d6de6a01cc
commit
3e016bd97f
@ -1,47 +1,18 @@
|
||||
package com.luoo.user.util;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
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 {
|
||||
int size = 4;
|
||||
|
||||
String[] content = new String[] { "~", "`", "@", "$", "%", "^", "&", "*", "+", "-", "|", ".", "<", ">" };
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
int total = 100000;
|
||||
int total = 1000000;
|
||||
System.out.println("total: " + total);
|
||||
StopWatch sw = new StopWatch();
|
||||
sw.start();
|
||||
IntStream.range(0, total).parallel().mapToObj(j -> getRandomNickName()).limit(100).forEach(System.out::println);
|
||||
for (int i = 4; i < 5; i++) {
|
||||
size = i;
|
||||
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);
|
||||
IntStream.range(0, total).parallel().mapToObj(j -> NickNameUtil.getRandomNickName()).limit(10)
|
||||
.forEach(System.out::println);
|
||||
long distinctNickName = IntStream.range(0, total).parallel().mapToObj(j -> NickNameUtil.getRandomNickName())
|
||||
.distinct().count();
|
||||
System.out.println("length: " + 9 + " distinctCount: " + distinctNickName);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in new issue