Is this you? As a journalist, you can create a free Muck Rack account to customize your profile, list your contact preferences, and upload a portfolio of your best work.
Claim your profile
Articles by import org.openjdk.jmh.infra.Blackhole
103.【Java Microbenchmark Harness】(三)
package org.openjdk.jmh.samples; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.util.concurrent.*; @OutputTimeUnit(TimeUnit.MICROSECONDS) // 报告时间单位 @BenchmarkMode(Mode.AverageTime) // 输出报告 @Warmup(iterations = 1,time = 1,timeUnit = TimeUnit.SECONDS) //预热次数和时间 @Measurement(iterations = 1,time = 1,timeUnit =...
DataInputStream数据读取 Vs ByteBuffer数据读取的巨大性能差距
背景: 今天在查找一个序列化和反序列化相关的问题时,意外发现使用DataInputStream读取和ByteBuffer读取之间性能相差巨大,本文就来记录下这两者在读取整数类型时的性能差异,以便在平时使用的过程中引起注意 DataInputStream数据读取 Vs ByteBuffer数据读取 我们会分别使用DataInputStream和ByteBuffer读取不同长度的字节数组,分别测试读取Short,Int,Long三类整数,然后分别看一下他们的性能 性能测试代码如下: package org.example.jmh.deserialize; import static java.util.concurrent.TimeUnit.MICROSECONDS; import static org.example.jmh.deserialize.DataUtil.createByteArray; import java.io.ByteArrayInputStream; import java.io.DataInput; import...
为什么list.sort()比Stream().sorted()更快?-51CTO.COM
看到一个评论,里面提到了list.sort()和list.strem().sorted()排序的差异。 说到list.sort()排序比stream().sorted()排序性能更好。 但没说到为什么。 有朋友也提到了这一点。 本文重新开始,先问是不是,再问为什么。 真的更好吗?
为什么list.sort()比Stream().sorted()更快? - 是奉壹呀 - 博客园
昨天写了一篇文章《小细节,大问题。分享一次代码优化的过程》,里面提到了list.sort()和list.strem().sorted()排序的差异。 说到list sort()排序比stream().sorted()排序性能更好。 但没说到为什么。 有朋友也提到了这一点。 本文重新开始,先问是不是,再问为什么。 真的更好吗? 先简单写个demo List<Integer> userList = new ArrayList<>(); Random rand = new Random(); for (int i = 0; i < 10000 ; i++) { userList.add(rand.nextInt(1000)); } List<Integer> userList2 = new ArrayList<>(); userList2.addAll(userList); Long startTime1 = System.currentTimeMillis();...
小细节,大问题。分享一次代码优化的过程 - 是奉壹呀 - 博客园
某个接口耗时大约8s,一开始我以为是io(主要是数据库)或者网络传输的瓶颈问题。 想着多半是SQL优化的问题。 接手一看,没有进行任何的IO操作或网络传输,仅仅是内存循环处理而已。 我的开发电脑cpu是i7 8代,其运算能力,大概是,整数51.74GIPS,浮点43.99GFLOPS 一个GFLOPS(gigaFLOPS)约等于每秒拾亿(=10^9)次的浮点运算 好家伙,也就是一秒大约440亿次浮点运算? 一般来说,现在的计算机,如果不是IO或网络瓶颈,你很难把一个接口整得很慢。 需求不说了,极致简化以后大概的性能瓶颈是,需要对两个list进行嵌套循环,伪代码 for (int i = 0; i < list2.size(); i++) { for (int j = 0; j < list.size(); j++) { list = list.stream().sorted(Comparator.comparing(e -> e.divide(BigDecimal.ONE))).collect(Collectors.toList()); // list.get(0) } } 1.
Comparing Map.of() and New HashMap() in Java
Java is a popular programming language used for developing a wide range of applications, including web, mobile, and desktop applications. It provides many useful data structures for developers to use in their programs, one of which is the Map interface. The Map interface is used to store data in key-value pairs, making it an essential data structure for many applications.
Use JMH for Your Java Applications With Gradle
If you want to benchmark your code, the Java Microbenchmark Harness is the tool of choice. In our example, we will use the refill-rate-limiter project. Since refill-rate-limiter uses Gradle, we will use the following plugin for Gradle: plugins { ... id "me.champeau.gradle.jmh" version "0.5.3" ... } We will place the benchmark in the jmh/java/io/github/resilience4j/ratelimiter folder.
Show More
loading
Actions
Is this you?
As a journalist, you can create a free Muck Rack account to customize your profile, list your contact preferences, and upload a portfolio of your best work.Get in touch with import
Contact import, search articles and posts on X, monitor coverage, and track replies from one place.
Learn more about Muck Rack