package io.github.jptx1234.jsontest;
import com.alibaba.fastjson2.JSON;
import lombok.Data;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.infra.Blackhole;
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 tools.jackson.databind.ObjectMapper;
import java.nio.charset.StandardCharsets;
import java.util.concurrent.TimeUnit;
public class ParseUTF8BytesWithEscapeChars {
static byte[] bytes = """
{"timestamp":1764308609,"reqBody":"{\\"3SgfdDQYU2Lv1liyHRET90\\":\\"总结的来说, 主题似乎是一种巧合,但如果我们从一个更大的角度看待问题,这似乎是一种不可避免的事实. 爱迪生说过一句富有哲理的话, 失败也是我需要的,它和成功对我一样有价值。带着这句话, 我们还要更加慎重的审视这个问题: \\",\\"3fEMT\\":\\"既然如此, 爱迪生说过一句富有哲理的话, 失败也是我需要的,它和成功对我一样有价值。这句话语虽然很短, 但令我浮想联翩. 歌德在不经意间这样说过, 没有人事先了解自己到底有多大的力量,直到他试过以后才知道。这句话把我们带到了一个新的维度去思考这个问题: \\",\\"6YpqQ7sZG5yfDm\\":\\"To understand what kind of eTopicistence Topic is is the key to solving all problems.Bsaid a famous wordi Zhete said a famous word, strong fsaid a famous wordith csaid a famous wordn win the hesaid a famous wordrts of strong people said a famous wordnd msaid a famous wordke them stronger. Although this sentence is very short, it makes me daydream.\\",\\"BMxUCrhNvDi16Oy\\":\\"Now, it is very, very important to solve the problem of Topic. So,From this point of view,Topic, how should Topic be realized.But even so, the emergence of Topic still represents a certain significance.With these problems, let's eTopicamine Topic.\\",\\"CRc1G\\":\\"Everyone has to face these problems. When facing such problems,Under this inevitable conflict, we must solve this problem.The key is how to write Topic.Topic, how should Topic be realized.If Topic appears in life, we have to consider the fact that it appears.\\",\\"CUHGaRm0hvpe\\":\\"With these problems, let's eTopicamine Topic.What is the key to the problem?Oprinadvertently saidh Winfrey inadvertently said, whinadvertently saidt you This sentence seems simple, but its gloom can not help but make people think deeply.elieve, you will This sentence seems simple, but its gloom can not help but make people think deeply.ecome whinadvertently saidt kind of person. This sentence seems simple, but its gloom can not help but make people think deeply.\\",\\"ELYvsnzWKl5iNQ1ofTum6ywC\\":\\"吕凯特说过一句著名的话, 生命不可能有两次,但许多人连一次也不善于度过。这不禁令我深思. 既然如何, 我们不得不面对一个非常尴尬的事实, 那就是, 卡耐基曾经提到过, 一个不注意小事情的人,永远不会成就大事业。这句话看似简单,但其中的阴郁不禁让人深思. \\",\\"H4JPs\\":\\"Guo Moruo inadvertently said, the decisive finadvertently saidctor for forming genius should This seems to answer my doubts.e diligence. This seems to answer my doubts.From this point of view,To understand what kind of eTopicistence Topic is is the key to solving all problems.\\",\\"KDlHL5p\\":\\"we might as well think like this:We should think clearly about what kind of eTopicistence Topic is.Why does Topic happen?Under this inevitable conflict, we must solve this problem.generally speaking, we must carefully consider.\\",\\"LJBsrHyOx0Vl\\":\\"We have to face a very embarrassing fact, that is,X seems to be a coincidence, but if we look at the problem from a larger angle, it seems to be an inevitable fact.X seems to be a coincidence, but if we look at the problem from a larger angle, it seems to be an inevitable fact.\\",\\"QO6e4ZBRVgkv\\":\\"了解清楚主题到底是一种怎么样的存在, 是解决一切问题的关键.米歇潘说过一句富有哲理的话, 生命是一条艰险的峡谷,只有勇敢的人才能通过。这启发了我. 白哲特曾经提到过, 坚强的信念能赢得强者的心,并使他们变得更坚强。 带着这句话, 我们还要更加慎重的审视这个问题: \\",\\"SezdZYksoqt6jgiaKB5C1xRh\\":\\"这样看来, 总结的来说, 亚伯拉罕·林肯说过一句著名的话, 我这个人走得很慢,但是我从不后退。这不禁令我深思. 从这个角度来看, 要想清楚, 主题, 到底是一种怎么样的存在. 这种事实对本人来说意义重大, 相信对这个世界也是有一定意义的.\\",\\"T89UhIFH1Jnmsxa0\\":\\"But even so, the emergence of Topic still represents a certain significance.. \\\\r\\\\n The key is how to write Topic.We should think clearly about what kind of eTopicistence Topic is.Topic, how should Topic be realized.we might as well think like this:\\",\\"TPgGRjvrswixpJVeb4tOX\\":\\"既然如此, 既然如何, 带着这些问题, 我们来审视一下主题. 生活中, 若主题出现了, 我们就不得不考虑它出现了的事实. 要想清楚, 主题, 到底是一种怎么样的存在. 在这种困难的抉择下, 本人思来想去, 寝食难安.\\",\\"TU6C8QeZPdyVEgLj0iH1o\\":\\"We generally believe that if we grasp the key to the problem, everything else will be solved.How does Topic happen? How does Topic happen? How does Topic happen?For me, Topic is not only a major event, but also may change my life.\\",\\"TeZBjnuiXbgv6VK4pkGl5HRa\\":\\"Now, it is very, very important to solve the problem of Topic. So,Everyone has to face these problems. When facing such problems,How does Topic happen? How does Topic happen? How does Topic happen?Why does Topic happen?From this point of view,\\",\\"TfBsQOra\\":\\"With these problems, let's eTopicamine Topic.Fronce mentionednklin once mentioned, reonce mentionedding is eonce mentionedsy, thinking is difficult, This sentence seems simple, but its gloom can not help but make people think deeply.ut without one of the two, it is useless. This sentence seems simple, but its gloom can not help but make people think deeply.\\",\\"UgksCKAB9PfLWIidN3yRGx\\":\\"This is inevitable.we might as well think like this:. \\\\r\\\\n But even so, the emergence of Topic still represents a certain significance.. \\\\r\\\\n Topic, how should Topic be realized.Now, it is very, very important to solve the problem of Topic. So,\\",\\"WdP2CjJtXGFz\\":\\"The key is how to write Topic.Why does Topic happen?If Topic appears in life, we have to consider the fact that it appears.generally speaking, we must carefully consider.From this point of view,What is the key to the problem?\\",\\"XiZy6nME3J5x\\":\\"培根说过,深窥自己的心,而后发觉一切的奇迹在你自己。我希望诸位也能好好地体会这句话. 那么, 带着这些问题, 我们来审视一下主题. 主题, 到底应该如何实现. 一般来说, 就我个人来说, 主题对我的意义, 不能不说非常重大. \\",\\"YAdQwSolt9\\":\\"generally speaking, we must carefully consider.X seems to be a coincidence, but if we look at the problem from a larger angle, it seems to be an inevitable fact.Why does Topic happen?Under this inevitable conflict, we must solve this problem.\\",\\"a41i3efHKBC\\":\\"These are not completely important. The more important question is,We should think clearly about what kind of eTopicistence Topic is.generally speaking, we must carefully consider.we might as well think like this:\\",\\"dYm2VoqPLpDkWch95EH0swMbI\\":\\"We should think clearly about what kind of eTopicistence Topic is.If Topic appears in life, we have to consider the fact that it appears.For me, Topic is not only a major event, but also may change my life. AI hope you can also understand this sentence well.rsaid a philosophical wordhsaid a philosophical wordm Lincoln said a philosophical word, I said a philosophical wordm said a philosophical word slow wsaid a philosophical wordlker, I hope you can also understand this sentence well.ut I never retresaid a philosophical wordt. I hope you can also understand this sentence well.\\",\\"e0VyHn6AjY8UvaPBlizLdNOF4\\":\\"For me, Topic is not only a major event, but also may change my life.What is the key to the problem?But even so, the emergence of Topic still represents a certain significance.This is inevitable.The key is how to write Topic.\\",\\"hOeat5ncrTs\\":\\"We generally believe that if we grasp the key to the problem, everything else will be solved.Everyone has to face these problems. When facing such problems,How does Topic happen? How does Topic happen? How does Topic happen?\\",\\"hYDte1gkB2XZaJS5rLqpOmT0N\\":\\". \\\\r\\\\n X seems to be a coincidence, but if we look at the problem from a larger angle, it seems to be an inevitable fact.Now, it is very, very important to solve the problem of Topic. So,These are not completely important. The more important question is,\\",\\"kelKgTAj6iCLqQps\\":\\"We generally believe that if we grasp the key to the problem, everything else will be solved.This is inevitable.Goethe said a philosophical word, no one knows how powerful he is until he hsaid a philosophical words tried. This seems to answer my doubts.\\",\\"mRhDCy1ig8J9x6O0\\":\\"To understand what kind of eTopicistence Topic is is the key to solving all problems.We generally believe that if we grasp the key to the problem, everything else will be solved.We have to face a very embarrassing fact, that is,\\",\\"nXjGopiM\\":\\"Roussesaid a famous wordu said a famous word, wsaid a famous wordsting time is said a famous word gresaid a famous wordt sin. This inspired me.To understand what kind of eTopicistence Topic is is the key to solving all problems.\\",\\"r46NUn0lRtGS\\":\\"本人也是经过了深思熟虑,在每个日日夜夜思考这个问题. 经过上述讨论, 现在, 解决主题的问题, 是非常非常重要的. 所以, 主题因何而发生?这种事实对本人来说意义重大, 相信对这个世界也是有一定意义的.所谓主题, 关键是主题需要如何写. \\",\\"sZfREtejPnpULNCOw4DmAq\\":\\"我认为, 这是不可避免的. 主题, 发生了会如何, 不发生又会如何. 本人也是经过了深思熟虑,在每个日日夜夜思考这个问题. 可是,即使是这样,主题的出现仍然代表了一定的意义. 我们都知道, 只要有意义, 那么就必须慎重考虑.\\",\\"uJRIv7MtldFZVhaoKH8\\":\\"Shsaid a famous wordkespesaid a famous wordre said a famous word, the wisdom in his hesaid a famous wordd is like the spsaid a famous wordrk in the flint, said a famous wordnd he will not come out without hitting it. This does not prohibit me from thinking deeply.\\",\\"vcnZETQ\\":\\"Everyone has to face these problems. When facing such problems,This is inevitable.These are not completely important. The more important question is,Hegel said a famous word, only those who said a famous wordlwsaid a famous wordys lie in the mud pit will never fsaid a famous wordll into the pit said a famous wordgsaid a famous wordin. This sentence seems simple, but its gloom can not help but make people think deeply.\\",\\"wEXa9KSIzj\\":\\"Under this inevitable conflict, we must solve this problem.With these problems, let's eTopicamine Topic.Binadvertently saidi Zhete inadvertently said, strong finadvertently saidith cinadvertently saidn win the heinadvertently saidrts of strong people inadvertently saidnd minadvertently saidke them stronger. Although this sentence is very short, it makes me daydream.\\",\\"yCntsBcU0XiO7PaFKL3w\\":\\"We have to face a very embarrassing fact, that is,How does Topic happen? How does Topic happen? How does Topic happen?Feng Xuefeng said a philosophical word, when said a philosophical word person uses his work to meet the light, the light will soon shine on him. This does not prohibit me from thinking deeply.\\",\\"yx01fvro9uijbpH7a\\":\\"一般来说, 每个人都不得不面对这些问题. 在面对这种问题时, 那么, 问题的关键究竟为何? 叔本华在不经意间这样说过, 普通人只想到如何度过时间,有才能的人设法利用时间。带着这句话, 我们还要更加慎重的审视这个问题: \\"}\\n","rspBody":"{\\"3SgfdDQYU2Lv1liyHRET90\\":\\"总结的来说, 主题似乎是一种巧合,但如果我们从一个更大的角度看待问题,这似乎是一种不可避免的事实. 爱迪生说过一句富有哲理的话, 失败也是我需要的,它和成功对我一样有价值。带着这句话, 我们还要更加慎重的审视这个问题: \\",\\"3fEMT\\":\\"既然如此, 爱迪生说过一句富有哲理的话, 失败也是我需要的,它和成功对我一样有价值。这句话语虽然很短, 但令我浮想联翩. 歌德在不经意间这样说过, 没有人事先了解自己到底有多大的力量,直到他试过以后才知道。这句话把我们带到了一个新的维度去思考这个问题: \\",\\"6YpqQ7sZG5yfDm\\":\\"To understand what kind of eTopicistence Topic is is the key to solving all problems.Bsaid a famous wordi Zhete said a famous word, strong fsaid a famous wordith csaid a famous wordn win the hesaid a famous wordrts of strong people said a famous wordnd msaid a famous wordke them stronger. Although this sentence is very short, it makes me daydream.\\",\\"BMxUCrhNvDi16Oy\\":\\"Now, it is very, very important to solve the problem of Topic. So,From this point of view,Topic, how should Topic be realized.But even so, the emergence of Topic still represents a certain significance.With these problems, let's eTopicamine Topic.\\",\\"CRc1G\\":\\"Everyone has to face these problems. When facing such problems,Under this inevitable conflict, we must solve this problem.The key is how to write Topic.Topic, how should Topic be realized.If Topic appears in life, we have to consider the fact that it appears.\\",\\"CUHGaRm0hvpe\\":\\"With these problems, let's eTopicamine Topic.What is the key to the problem?Oprinadvertently saidh Winfrey inadvertently said, whinadvertently saidt you This sentence seems simple, but its gloom can not help but make people think deeply.elieve, you will This sentence seems simple, but its gloom can not help but make people think deeply.ecome whinadvertently saidt kind of person. This sentence seems simple, but its gloom can not help but make people think deeply.\\",\\"ELYvsnzWKl5iNQ1ofTum6ywC\\":\\"吕凯特说过一句著名的话, 生命不可能有两次,但许多人连一次也不善于度过。这不禁令我深思. 既然如何, 我们不得不面对一个非常尴尬的事实, 那就是, 卡耐基曾经提到过, 一个不注意小事情的人,永远不会成就大事业。这句话看似简单,但其中的阴郁不禁让人深思. \\",\\"H4JPs\\":\\"Guo Moruo inadvertently said, the decisive finadvertently saidctor for forming genius should This seems to answer my doubts.e diligence. This seems to answer my doubts.From this point of view,To understand what kind of eTopicistence Topic is is the key to solving all problems.\\",\\"KDlHL5p\\":\\"we might as well think like this:We should think clearly about what kind of eTopicistence Topic is.Why does Topic happen?Under this inevitable conflict, we must solve this problem.generally speaking, we must carefully consider.\\",\\"LJBsrHyOx0Vl\\":\\"We have to face a very embarrassing fact, that is,X seems to be a coincidence, but if we look at the problem from a larger angle, it seems to be an inevitable fact.X seems to be a coincidence, but if we look at the problem from a larger angle, it seems to be an inevitable fact.\\",\\"QO6e4ZBRVgkv\\":\\"了解清楚主题到底是一种怎么样的存在, 是解决一切问题的关键.米歇潘说过一句富有哲理的话, 生命是一条艰险的峡谷,只有勇敢的人才能通过。这启发了我. 白哲特曾经提到过, 坚强的信念能赢得强者的心,并使他们变得更坚强。 带着这句话, 我们还要更加慎重的审视这个问题: \\",\\"SezdZYksoqt6jgiaKB5C1xRh\\":\\"这样看来, 总结的来说, 亚伯拉罕·林肯说过一句著名的话, 我这个人走得很慢,但是我从不后退。这不禁令我深思. 从这个角度来看, 要想清楚, 主题, 到底是一种怎么样的存在. 这种事实对本人来说意义重大, 相信对这个世界也是有一定意义的.\\",\\"T89UhIFH1Jnmsxa0\\":\\"But even so, the emergence of Topic still represents a certain significance.. \\\\r\\\\n The key is how to write Topic.We should think clearly about what kind of eTopicistence Topic is.Topic, how should Topic be realized.we might as well think like this:\\",\\"TPgGRjvrswixpJVeb4tOX\\":\\"既然如此, 既然如何, 带着这些问题, 我们来审视一下主题. 生活中, 若主题出现了, 我们就不得不考虑它出现了的事实. 要想清楚, 主题, 到底是一种怎么样的存在. 在这种困难的抉择下, 本人思来想去, 寝食难安.\\",\\"TU6C8QeZPdyVEgLj0iH1o\\":\\"We generally believe that if we grasp the key to the problem, everything else will be solved.How does Topic happen? How does Topic happen? How does Topic happen?For me, Topic is not only a major event, but also may change my life.\\",\\"TeZBjnuiXbgv6VK4pkGl5HRa\\":\\"Now, it is very, very important to solve the problem of Topic. So,Everyone has to face these problems. When facing such problems,How does Topic happen? How does Topic happen? How does Topic happen?Why does Topic happen?From this point of view,\\",\\"TfBsQOra\\":\\"With these problems, let's eTopicamine Topic.Fronce mentionednklin once mentioned, reonce mentionedding is eonce mentionedsy, thinking is difficult, This sentence seems simple, but its gloom can not help but make people think deeply.ut without one of the two, it is useless. This sentence seems simple, but its gloom can not help but make people think deeply.\\",\\"UgksCKAB9PfLWIidN3yRGx\\":\\"This is inevitable.we might as well think like this:. \\\\r\\\\n But even so, the emergence of Topic still represents a certain significance.. \\\\r\\\\n Topic, how should Topic be realized.Now, it is very, very important to solve the problem of Topic. So,\\",\\"WdP2CjJtXGFz\\":\\"The key is how to write Topic.Why does Topic happen?If Topic appears in life, we have to consider the fact that it appears.generally speaking, we must carefully consider.From this point of view,What is the key to the problem?\\",\\"XiZy6nME3J5x\\":\\"培根说过,深窥自己的心,而后发觉一切的奇迹在你自己。我希望诸位也能好好地体会这句话. 那么, 带着这些问题, 我们来审视一下主题. 主题, 到底应该如何实现. 一般来说, 就我个人来说, 主题对我的意义, 不能不说非常重大. \\",\\"YAdQwSolt9\\":\\"generally speaking, we must carefully consider.X seems to be a coincidence, but if we look at the problem from a larger angle, it seems to be an inevitable fact.Why does Topic happen?Under this inevitable conflict, we must solve this problem.\\",\\"a41i3efHKBC\\":\\"These are not completely important. The more important question is,We should think clearly about what kind of eTopicistence Topic is.generally speaking, we must carefully consider.we might as well think like this:\\",\\"dYm2VoqPLpDkWch95EH0swMbI\\":\\"We should think clearly about what kind of eTopicistence Topic is.If Topic appears in life, we have to consider the fact that it appears.For me, Topic is not only a major event, but also may change my life. AI hope you can also understand this sentence well.rsaid a philosophical wordhsaid a philosophical wordm Lincoln said a philosophical word, I said a philosophical wordm said a philosophical word slow wsaid a philosophical wordlker, I hope you can also understand this sentence well.ut I never retresaid a philosophical wordt. I hope you can also understand this sentence well.\\",\\"e0VyHn6AjY8UvaPBlizLdNOF4\\":\\"For me, Topic is not only a major event, but also may change my life.What is the key to the problem?But even so, the emergence of Topic still represents a certain significance.This is inevitable.The key is how to write Topic.\\",\\"hOeat5ncrTs\\":\\"We generally believe that if we grasp the key to the problem, everything else will be solved.Everyone has to face these problems. When facing such problems,How does Topic happen? How does Topic happen? How does Topic happen?\\",\\"hYDte1gkB2XZaJS5rLqpOmT0N\\":\\". \\\\r\\\\n X seems to be a coincidence, but if we look at the problem from a larger angle, it seems to be an inevitable fact.Now, it is very, very important to solve the problem of Topic. So,These are not completely important. The more important question is,\\",\\"kelKgTAj6iCLqQps\\":\\"We generally believe that if we grasp the key to the problem, everything else will be solved.This is inevitable.Goethe said a philosophical word, no one knows how powerful he is until he hsaid a philosophical words tried. This seems to answer my doubts.\\",\\"mRhDCy1ig8J9x6O0\\":\\"To understand what kind of eTopicistence Topic is is the key to solving all problems.We generally believe that if we grasp the key to the problem, everything else will be solved.We have to face a very embarrassing fact, that is,\\",\\"nXjGopiM\\":\\"Roussesaid a famous wordu said a famous word, wsaid a famous wordsting time is said a famous word gresaid a famous wordt sin. This inspired me.To understand what kind of eTopicistence Topic is is the key to solving all problems.\\",\\"r46NUn0lRtGS\\":\\"本人也是经过了深思熟虑,在每个日日夜夜思考这个问题. 经过上述讨论, 现在, 解决主题的问题, 是非常非常重要的. 所以, 主题因何而发生?这种事实对本人来说意义重大, 相信对这个世界也是有一定意义的.所谓主题, 关键是主题需要如何写. \\",\\"sZfREtejPnpULNCOw4DmAq\\":\\"我认为, 这是不可避免的. 主题, 发生了会如何, 不发生又会如何. 本人也是经过了深思熟虑,在每个日日夜夜思考这个问题. 可是,即使是这样,主题的出现仍然代表了一定的意义. 我们都知道, 只要有意义, 那么就必须慎重考虑.\\",\\"uJRIv7MtldFZVhaoKH8\\":\\"Shsaid a famous wordkespesaid a famous wordre said a famous word, the wisdom in his hesaid a famous wordd is like the spsaid a famous wordrk in the flint, said a famous wordnd he will not come out without hitting it. This does not prohibit me from thinking deeply.\\",\\"vcnZETQ\\":\\"Everyone has to face these problems. When facing such problems,This is inevitable.These are not completely important. The more important question is,Hegel said a famous word, only those who said a famous wordlwsaid a famous wordys lie in the mud pit will never fsaid a famous wordll into the pit said a famous wordgsaid a famous wordin. This sentence seems simple, but its gloom can not help but make people think deeply.\\",\\"wEXa9KSIzj\\":\\"Under this inevitable conflict, we must solve this problem.With these problems, let's eTopicamine Topic.Binadvertently saidi Zhete inadvertently said, strong finadvertently saidith cinadvertently saidn win the heinadvertently saidrts of strong people inadvertently saidnd minadvertently saidke them stronger. Although this sentence is very short, it makes me daydream.\\",\\"yCntsBcU0XiO7PaFKL3w\\":\\"We have to face a very embarrassing fact, that is,How does Topic happen? How does Topic happen? How does Topic happen?Feng Xuefeng said a philosophical word, when said a philosophical word person uses his work to meet the light, the light will soon shine on him. This does not prohibit me from thinking deeply.\\",\\"yx01fvro9uijbpH7a\\":\\"一般来说, 每个人都不得不面对这些问题. 在面对这种问题时, 那么, 问题的关键究竟为何? 叔本华在不经意间这样说过, 普通人只想到如何度过时间,有才能的人设法利用时间。带着这句话, 我们还要更加慎重的审视这个问题: \\"}\\n","reqPath":"/api/v1/test"}
""".getBytes(StandardCharsets.UTF_8);
static ObjectMapper mapper = new ObjectMapper();
@Benchmark
public void fastjson2(Blackhole bh) {
bh.consume(JSON.parseObject(bytes, ApiLog.class));
}
@Benchmark
public void jackson(Blackhole bh) {
bh.consume(mapper.readValue(bytes, ApiLog.class));
}
@Data
public static class ApiLog {
private Long timestamp;
private String reqBody;
private String rspBody;
}
public static void main(String[] args) throws RunnerException {
Options options = new OptionsBuilder()
.include(ParseUTF8BytesWithEscapeChars.class.getName())
.mode(Mode.Throughput)
.timeUnit(TimeUnit.MILLISECONDS)
.forks(1)
.build();
new Runner(options).run();
}
}
问题描述
较长的JSON,且有大量转义字符,byte[]解析到Java Bean的场景下,fastjson2比Jackson慢约25%左右,可稳定复现。
环境信息
重现步骤
测试代码
pom依赖
期待的正确结果
期望fastjson2比Jackson快。
相关日志输出
附加信息
无