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