From 6d1ab573227dcb1928ad74cf25ed92ac8381691e Mon Sep 17 00:00:00 2001 From: 05412 <2738076308@qq.com> Date: Tue, 23 Jul 2024 11:42:46 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E6=80=A7=E8=83=BD=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/test/java/dev/surl/surl/Benchmark.kt | 41 ------------------------ 1 file changed, 41 deletions(-) delete mode 100644 src/test/java/dev/surl/surl/Benchmark.kt diff --git a/src/test/java/dev/surl/surl/Benchmark.kt b/src/test/java/dev/surl/surl/Benchmark.kt deleted file mode 100644 index 6f3fd30..0000000 --- a/src/test/java/dev/surl/surl/Benchmark.kt +++ /dev/null @@ -1,41 +0,0 @@ -package dev.surl.surl - -import dev.surl.surl.service.SurlService -import dev.surl.surl.util.genSnowflakeUID -import kotlinx.coroutines.launch -import kotlinx.coroutines.runBlocking -import org.junit.jupiter.api.Test -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.context.SpringBootTest - -@SpringBootTest -class Benchmark { - @Test - fun tpsTest(@Autowired service: SurlService) { - val now = System.currentTimeMillis() - runBlocking { - for(i in 1..128) { - launch { - for (j in 1..100) { - service.addSurl("https://surl.org/${genSnowflakeUID()}") - } - } - } - } - val timeEllapsed = System.currentTimeMillis() - now - println("one by one TPS: ${128 * 100.0 * 1000 / timeEllapsed}") - } - @Test - fun `test batch insert`(@Autowired service: SurlService) { - runBlocking { - val urls = mutableListOf() - for(i in 1..10000) { - urls.add("https://surl.org/${genSnowflakeUID()}") - } - val now = System.currentTimeMillis() - service.batchAddSurl(urls) - val timeEllapsed = System.currentTimeMillis() - now - println("batch TPS: ${10000 * 1000 / timeEllapsed}") - } - } -} \ No newline at end of file