Skip to content

Commit

Permalink
将一百万条数据插入并测试HyperLogLog的误差和内存占用情况
Browse files Browse the repository at this point in the history
  • Loading branch information
RealOhYeah committed Apr 28, 2024
1 parent 73f1ea4 commit d9b3cbe
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions dianping/src/test/java/com/hmdp/HmDianPingApplicationTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,25 @@ void loadShopData() {
}


/**
* 将一百万条数据插入并测试HyperLogLog的误差和内存占用情况
*/
@Test
void testHyperLogLog() {
String[] values = new String[1000];
int j = 0;
for (int i = 0; i < 1000000; i++) {
j = i % 1000;
values[j] = "user_" + i;
if(j == 999){
// 发送到Redis
stringRedisTemplate.opsForHyperLogLog().add("hl2", values);
}
}
// 统计数量
Long count = stringRedisTemplate.opsForHyperLogLog().size("hl2");
System.out.println("count = " + count);
}


}

0 comments on commit d9b3cbe

Please sign in to comment.