移除性能测试

This commit is contained in:
05412 2024-07-23 11:42:46 +08:00
parent 631a386bd4
commit 6d1ab57322

View File

@ -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<String>()
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}")
}
}
}