SpringCloud Gateway 路由轉發性能優化

{"type":"doc","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https://xie.infoq.cn/article/d39fde1ce527ec2c3c6750c4c","title":"","type":null},"content":[{"type":"text","text":"接上篇","attrs":{}}]},{"type":"text","text":",通過測試驗證,發現隨着路由增長,路由性能會嚴重下降。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"本篇,針對採用Path方式路由的進行性能優化,","attrs":{}},{"type":"text","marks":[{"type":"color","attrs":{"color":"#F5222D","name":"red"}}],"text":"注意該【優化","attrs":{}},{"type":"text","marks":[{"type":"color","attrs":{"color":"#F5222D","name":"user"}}],"text":"】","attrs":{}},{"type":"text","marks":[{"type":"color","attrs":{"color":"#F5222D","name":"red"}}],"text":"僅適用於特定場景,不具備普適性","attrs":{}},{"type":"text","text":"。","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"查閱和修改源碼","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"通過閱讀 ","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https://github.com/spring-cloud/spring-cloud-gateway/blob/v3.0.3/spring-cloud-gateway-server/src/main/java/org/springframework/cloud/gateway/handler/RoutePredicateHandlerMapping.java","title":"","type":null},"content":[{"type":"text","text":"RoutePredicateHandlerMapping.java","attrs":{}}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"這個類是SpringCloud Gateway接收Web請求,並查找匹配路由,具體方法爲:","attrs":{}}]},{"type":"codeblock","attrs":{"lang":"java"},"content":[{"type":"text","text":"protected Mono lookupRoute(ServerWebExchange exchange) {\n return this.routeLocator.getRoutes()\n // individually filter routes so that filterWhen error delaying is not a\n // problem\n .concatMap(route -> Mono.just(route).filterWhen(r -> {\n // add the current route we are testing\n exchange.getAttributes().put(GATEWAY_PREDICATE_ROUTE_ATTR, r.getId());\n return r.getPredicate().apply(exchange);\n })\n // instead of immediately stopping main flux due to error, log and\n // swallow it\n .doOnError(e -> logger.error(\"Error applying predicate for route: \" + route.getId(), e))\n .onErrorResume(e -> Mono.empty()))\n // .defaultIfEmpty() put a static Route not found\n // or .switchIfEmpty()\n // .switchIfEmpty(Mono.empty().log(\"noroute\"))\n .next()\n // TODO: error handling\n .map(route -> {\n if (logger.isDebugEnabled()) {\n logger.debug(\"Route matched: \" + route.getId());\n }\n validateRoute(route, exchange);\n return route;\n });\n /*\n * TODO: trace logging if (logger.isTraceEnabled()) {\n * logger.trace(\"RouteDefinition did not match: \" + routeDefinition.getId()); }\n */\n}","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"對代碼進行修改,如果Path匹配 ","attrs":{}},{"type":"codeinline","content":[{"type":"text","text":"/mock/**","attrs":{}}],"attrs":{}},{"type":"text","text":" 則對路由查找結果進行緩存,代碼如下","attrs":{}}]},{"type":"codeblock","attrs":{"lang":"java"},"content":[{"type":"text","text":"public static final String MOCK_PATCH = \"/mock/**\";\nprivate Map hashCache = new ConcurrentHashMap<>(1024);\n\nprotected Mono lookupRoute(ServerWebExchange exchange) {\n String path = exchange.getRequest().getPath().subPath(0).value();\n //符合Path規則,優先從緩存Map獲取,時間複雜度近似於O(1)\n if (pathMatcher.match(MOCK_PATCH, path)) {\n return Mono.justOrEmpty(hashCache.get(path))\n .switchIfEmpty(getRouteMono(exchange, path));\n }\n return getRouteMono(exchange, path);\n}\n\nprivate Mono getRouteMono(ServerWebExchange exchange, String path) {\n return this.routeLocator.getRoutes()\n // individually filter routes so that filterWhen error delaying is not a\n // problem\n .concatMap(route -> Mono.just(route).filterWhen(r -> {\n // add the current route we are testing\n exchange.getAttributes().put(GATEWAY_PREDICATE_ROUTE_ATTR, r.getId());\n return r.getPredicate().apply(exchange);\n })\n // instead of immediately stopping main flux due to error, log and\n // swallow it\n .doOnError(e -> logger.error(\"Error applying predicate for route: \" + route.getId(), e))\n .onErrorResume(e -> Mono.empty()))\n // .defaultIfEmpty() put a static Route not found\n // or .switchIfEmpty()\n // .switchIfEmpty(Mono.empty().log(\"noroute\"))\n .next()\n // TODO: error handling\n .map(route -> {\n if (logger.isDebugEnabled()) {\n logger.debug(\"Route matched: \" + route.getId());\n }\n validateRoute(route, exchange);\n //符合Path規則,緩存路由\n if (pathMatcher.match(MOCK_PATCH, path)) {\n hashCache.put(path, route);\n }\n return route;\n });\n}","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"繼續翻閱源碼,找到","attrs":{}},{"type":"link","attrs":{"href":"https://github.com/spring-cloud/spring-cloud-gateway/blob/v3.0.3/spring-cloud-gateway-server/src/main/java/org/springframework/cloud/gateway/handler/RoutePredicateHandlerMapping.java","title":"","type":null},"content":[{"type":"text","text":"RoutePredicateHandlerMapping","attrs":{}}]},{"type":"text","text":" 是如何裝配的,在","attrs":{}},{"type":"link","attrs":{"href":"https://github.com/spring-cloud/spring-cloud-gateway/blob/v3.0.3/spring-cloud-gateway-server/src/main/java/org/springframework/cloud/gateway/config/GatewayAutoConfiguration.java","title":"","type":null},"content":[{"type":"text","text":"GatewayAutoConfiguration","attrs":{}}]},{"type":"text","text":" 中實現了SpringCloud Gateway內部組件的自動裝配,","attrs":{}},{"type":"link","attrs":{"href":"https://github.com/spring-cloud/spring-cloud-gateway/blob/v3.0.3/spring-cloud-gateway-server/src/main/java/org/springframework/cloud/gateway/handler/RoutePredicateHandlerMapping.java","title":"","type":null},"content":[{"type":"text","text":"RoutePredicateHandlerMapping","attrs":{}}]},{"type":"text","text":" 也在其中,代碼入下:","attrs":{}}]},{"type":"codeblock","attrs":{"lang":"java"},"content":[{"type":"text","text":"@Bean\npublic RoutePredicateHandlerMapping routePredicateHandlerMapping(FilteringWebHandler webHandler,\n RouteLocator routeLocator, GlobalCorsProperties globalCorsProperties, Environment environment) {\n return new RoutePredicateHandlerMapping(webHandler, routeLocator, globalCorsProperties, environment);\n}","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"很遺憾,官方沒有給我們留有餘地,這個裝配是沒有條件的,我們無法自行裝配替代默認裝配。","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"至此,我們有兩個方案:","attrs":{}}]},{"type":"numberedlist","attrs":{"start":1,"normalizeStart":1},"content":[{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":1,"align":null,"origin":null},"content":[{"type":"text","text":"修改SpringCloud Gateway源,並碼構件我們自己的jar包,該方案以上修改已經足夠,下載並修改源碼後執行 ","attrs":{}},{"type":"codeinline","content":[{"type":"text","text":"mvn install","attrs":{}}],"attrs":{}},{"type":"text","text":" 安裝到本地即可。","attrs":{}}]}]},{"type":"listitem","attrs":{"listStyle":null},"content":[{"type":"paragraph","attrs":{"indent":0,"number":2,"align":null,"origin":null},"content":[{"type":"text","text":"繼續查找","attrs":{}},{"type":"link","attrs":{"href":"https://github.com/spring-cloud/spring-cloud-gateway/blob/v3.0.3/spring-cloud-gateway-server/src/main/java/org/springframework/cloud/gateway/config/GatewayAutoConfiguration.java","title":"","type":null},"content":[{"type":"text","text":"GatewayAutoConfiguration","attrs":{}}]},{"type":"text","text":" 的裝配方式,尋找拓展點。","attrs":{}}]}]}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"尋找裝配點","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"查閱","attrs":{}},{"type":"link","attrs":{"href":"https://github.com/spring-cloud/spring-cloud-gateway/blob/v3.0.3/spring-cloud-gateway-server/src/main/java/org/springframework/cloud/gateway/config/GatewayAutoConfiguration.java","title":"","type":null},"content":[{"type":"text","text":"GatewayAutoConfiguration","attrs":{}}]},{"type":"text","text":" 源碼,類定義頭部有一個裝配條件:","attrs":{}}]},{"type":"codeblock","attrs":{"lang":"java"},"content":[{"type":"text","text":"@Configuration(proxyBeanMethods = false)\n// 該條件可以作爲裝配點\n@ConditionalOnProperty(name = \"spring.cloud.gateway.enabled\", matchIfMissing = true)\n@EnableConfigurationProperties\n@AutoConfigureBefore({ HttpHandlerAutoConfiguration.class, WebFluxAutoConfiguration.class })\n@AutoConfigureAfter({ GatewayReactiveLoadBalancerClientAutoConfiguration.class,\n\t\tGatewayClassPathWarningAutoConfiguration.class })\n@ConditionalOnClass(DispatcherHandler.class)\npublic class GatewayAutoConfiguration","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"可以在配置文件中配置","attrs":{}}]},{"type":"codeblock","attrs":{"lang":"java"},"content":[{"type":"text","text":"spring.cloud.gateway.enabled=false","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"然後將","attrs":{}},{"type":"link","attrs":{"href":"https://github.com/spring-cloud/spring-cloud-gateway/blob/v3.0.3/spring-cloud-gateway-server/src/main/java/org/springframework/cloud/gateway/config/GatewayAutoConfiguration.java","title":"","type":null},"content":[{"type":"text","text":"GatewayAutoConfiguration","attrs":{}}]},{"type":"text","text":" 拷貝到我們自己的工程中,去掉裝配條件","attrs":{}}]},{"type":"codeblock","attrs":{"lang":"java"},"content":[{"type":"text","text":"// @ConditionalOnProperty(name = \"spring.cloud.gateway.enabled\", matchIfMissing = true)","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"同樣的,我們需要找到所有依賴此條件裝配的類,進行上述操作","attrs":{}}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/04/045899a05cf2b8526e634b2e9a6e8f01.png","alt":null,"title":"","style":[{"key":"width","value":"100%"},{"key":"bordertype","value":"none"}],"href":"","fromPaste":false,"pastePass":false}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/b2/b2450b2ccd29a32dd1203c6d7ab3a0b3.png","alt":null,"title":"","style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":"","fromPaste":false,"pastePass":false}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"至此修改完成,可以進行下一步測試驗證。","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"測試結果","attrs":{}}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/42/42c2b4a19fd84eaece2c3d8e368785ed.png","alt":null,"title":"","style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":"","fromPaste":false,"pastePass":false}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/6c/6c63628668ed45fbeafa7ef99f02663a.png","alt":null,"title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/d4/d46bf3b48455173704845cbff1d9ff24.png","alt":null,"title":null,"style":[{"key":"width","value":"75%"},{"key":"bordertype","value":"none"}],"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"通過以上圖表對比,可以發現,改造後,路由轉發性能與路由表大小沒有直接關聯關係了,性能得到了較大提升。","attrs":{}}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"源碼下載","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https://gitee.com/eblog/scgw-benchmark-all","title":"","type":null},"content":[{"type":"text","text":"https://gitee.com/eblog/scgw-benchmark-all","attrs":{}}]}]},{"type":"heading","attrs":{"align":null,"level":2},"content":[{"type":"text","text":"測試記錄","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"直連對照組","attrs":{}}]},{"type":"codeblock","attrs":{"lang":"text"},"content":[{"type":"text","text":"Benchmark Mode Cnt Score Error Units\nMyBenchmark.testMethod thrpt 20 990.298 ± 219.989 ops/s\nMyBenchmark.testMethod avgt 20 0.002 ± 0.001 s/op\nMyBenchmark.testMethod sample 20205 0.002 ± 0.001 s/op\nMyBenchmark.testMethod:testMethod·p0.00 sample 0.001 s/op\nMyBenchmark.testMethod:testMethod·p0.50 sample 0.002 s/op\nMyBenchmark.testMethod:testMethod·p0.90 sample 0.003 s/op\nMyBenchmark.testMethod:testMethod·p0.95 sample 0.003 s/op\nMyBenchmark.testMethod:testMethod·p0.99 sample 0.004 s/op\nMyBenchmark.testMethod:testMethod·p0.999 sample 0.011 s/op\nMyBenchmark.testMethod:testMethod·p0.9999 sample 0.017 s/op\nMyBenchmark.testMethod:testMethod·p1.00 sample 0.017 s/op\nMyBenchmark.testMethod ss 20 0.002 ± 0.001 s/op","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"100條路由(老版本)","attrs":{}}]},{"type":"codeblock","attrs":{"lang":null},"content":[{"type":"text","text":"Benchmark Mode Cnt Score Error Units\nMyBenchmark.testMethod thrpt 20 769.948 ± 112.572 ops/s\nMyBenchmark.testMethod avgt 20 0.003 ± 0.001 s/op\nMyBenchmark.testMethod sample 15364 0.003 ± 0.001 s/op\nMyBenchmark.testMethod:testMethod·p0.00 sample 0.002 s/op\nMyBenchmark.testMethod:testMethod·p0.50 sample 0.002 s/op\nMyBenchmark.testMethod:testMethod·p0.90 sample 0.004 s/op\nMyBenchmark.testMethod:testMethod·p0.95 sample 0.004 s/op\nMyBenchmark.testMethod:testMethod·p0.99 sample 0.004 s/op\nMyBenchmark.testMethod:testMethod·p0.999 sample 0.008 s/op\nMyBenchmark.testMethod:testMethod·p0.9999 sample 0.015 s/op\nMyBenchmark.testMethod:testMethod·p1.00 sample 0.015 s/op\nMyBenchmark.testMethod ss 20 0.003 ± 0.001 s/op","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"100條路由(新版本)","attrs":{}}]},{"type":"codeblock","attrs":{"lang":null},"content":[{"type":"text","text":"Benchmark Mode Cnt Score Error Units\nMyBenchmark.testMethod thrpt 20 769.099 ± 110.400 ops/s\nMyBenchmark.testMethod avgt 20 0.003 ± 0.001 s/op\nMyBenchmark.testMethod sample 15541 0.003 ± 0.001 s/op\nMyBenchmark.testMethod:testMethod·p0.00 sample 0.002 s/op\nMyBenchmark.testMethod:testMethod·p0.50 sample 0.002 s/op\nMyBenchmark.testMethod:testMethod·p0.90 sample 0.003 s/op\nMyBenchmark.testMethod:testMethod·p0.95 sample 0.004 s/op\nMyBenchmark.testMethod:testMethod·p0.99 sample 0.004 s/op\nMyBenchmark.testMethod:testMethod·p0.999 sample 0.008 s/op\nMyBenchmark.testMethod:testMethod·p0.9999 sample 0.012 s/op\nMyBenchmark.testMethod:testMethod·p1.00 sample 0.012 s/op\nMyBenchmark.testMethod ss 20 0.003 ± 0.001 s/op","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"1K條路由(老版本)","attrs":{}}]},{"type":"codeblock","attrs":{"lang":"text"},"content":[{"type":"text","text":"Benchmark Mode Cnt Score Error Units\nMyBenchmark.testMethod thrpt 20 759.265 ± 106.047 ops/s\nMyBenchmark.testMethod avgt 20 0.003 ± 0.001 s/op\nMyBenchmark.testMethod sample 15245 0.003 ± 0.001 s/op\nMyBenchmark.testMethod:testMethod·p0.00 sample 0.001 s/op\nMyBenchmark.testMethod:testMethod·p0.50 sample 0.003 s/op\nMyBenchmark.testMethod:testMethod·p0.90 sample 0.003 s/op\nMyBenchmark.testMethod:testMethod·p0.95 sample 0.004 s/op\nMyBenchmark.testMethod:testMethod·p0.99 sample 0.004 s/op\nMyBenchmark.testMethod:testMethod·p0.999 sample 0.007 s/op\nMyBenchmark.testMethod:testMethod·p0.9999 sample 0.014 s/op\nMyBenchmark.testMethod:testMethod·p1.00 sample 0.015 s/op\nMyBenchmark.testMethod ss 20 0.003 ± 0.001 s/op","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"1K條路由(新版本)","attrs":{}}]},{"type":"codeblock","attrs":{"lang":"text"},"content":[{"type":"text","text":"Benchmark Mode Cnt Score Error Units\nMyBenchmark.testMethod thrpt 20 772.978 ± 102.976 ops/s\nMyBenchmark.testMethod avgt 20 0.003 ± 0.001 s/op\nMyBenchmark.testMethod sample 15101 0.003 ± 0.001 s/op\nMyBenchmark.testMethod:testMethod·p0.00 sample 0.002 s/op\nMyBenchmark.testMethod:testMethod·p0.50 sample 0.003 s/op\nMyBenchmark.testMethod:testMethod·p0.90 sample 0.003 s/op\nMyBenchmark.testMethod:testMethod·p0.95 sample 0.004 s/op\nMyBenchmark.testMethod:testMethod·p0.99 sample 0.004 s/op\nMyBenchmark.testMethod:testMethod·p0.999 sample 0.007 s/op\nMyBenchmark.testMethod:testMethod·p0.9999 sample 0.016 s/op\nMyBenchmark.testMethod:testMethod·p1.00 sample 0.016 s/op\nMyBenchmark.testMethod ss 20 0.003 ± 0.001 s/op","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"5K條路由(老版本)","attrs":{}}]},{"type":"codeblock","attrs":{"lang":null},"content":[{"type":"text","text":"Benchmark Mode Cnt Score Error Units\nMyBenchmark.testMethod thrpt 20 232.624 ± 3.330 ops/s\nMyBenchmark.testMethod avgt 20 0.008 ± 0.001 s/op\nMyBenchmark.testMethod sample 4734 0.009 ± 0.001 s/op\nMyBenchmark.testMethod:testMethod·p0.00 sample 0.008 s/op\nMyBenchmark.testMethod:testMethod·p0.50 sample 0.008 s/op\nMyBenchmark.testMethod:testMethod·p0.90 sample 0.009 s/op\nMyBenchmark.testMethod:testMethod·p0.95 sample 0.009 s/op\nMyBenchmark.testMethod:testMethod·p0.99 sample 0.011 s/op\nMyBenchmark.testMethod:testMethod·p0.999 sample 0.015 s/op\nMyBenchmark.testMethod:testMethod·p0.9999 sample 0.016 s/op\nMyBenchmark.testMethod:testMethod·p1.00 sample 0.016 s/op\nMyBenchmark.testMethod ss 20 0.009 ± 0.001 s/op","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"5K條路由(新版本)","attrs":{}}]},{"type":"codeblock","attrs":{"lang":null},"content":[{"type":"text","text":"Benchmark Mode Cnt Score Error Units\nMyBenchmark.testMethod thrpt 20 783.074 ± 112.114 ops/s\nMyBenchmark.testMethod avgt 20 0.003 ± 0.001 s/op\nMyBenchmark.testMethod sample 15318 0.003 ± 0.001 s/op\nMyBenchmark.testMethod:testMethod·p0.00 sample 0.001 s/op\nMyBenchmark.testMethod:testMethod·p0.50 sample 0.002 s/op\nMyBenchmark.testMethod:testMethod·p0.90 sample 0.004 s/op\nMyBenchmark.testMethod:testMethod·p0.95 sample 0.004 s/op\nMyBenchmark.testMethod:testMethod·p0.99 sample 0.004 s/op\nMyBenchmark.testMethod:testMethod·p0.999 sample 0.007 s/op\nMyBenchmark.testMethod:testMethod·p0.9999 sample 0.017 s/op\nMyBenchmark.testMethod:testMethod·p1.00 sample 0.017 s/op\nMyBenchmark.testMethod ss 20 0.003 ± 0.001 s/op","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"1W條路由(老版本)","attrs":{}}]},{"type":"codeblock","attrs":{"lang":null},"content":[{"type":"text","text":"Benchmark Mode Cnt Score Error Units\nMyBenchmark.testMethod thrpt 20 122.122 ± 1.789 ops/s\nMyBenchmark.testMethod avgt 20 0.016 ± 0.001 s/op\nMyBenchmark.testMethod sample 2464 0.016 ± 0.001 s/op\nMyBenchmark.testMethod:testMethod·p0.00 sample 0.015 s/op\nMyBenchmark.testMethod:testMethod·p0.50 sample 0.016 s/op\nMyBenchmark.testMethod:testMethod·p0.90 sample 0.017 s/op\nMyBenchmark.testMethod:testMethod·p0.95 sample 0.018 s/op\nMyBenchmark.testMethod:testMethod·p0.99 sample 0.018 s/op\nMyBenchmark.testMethod:testMethod·p0.999 sample 0.029 s/op\nMyBenchmark.testMethod:testMethod·p0.9999 sample 0.030 s/op\nMyBenchmark.testMethod:testMethod·p1.00 sample 0.030 s/op\nMyBenchmark.testMethod ss 20 0.017 ± 0.001 s/op","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"1W條路由(新版本)","attrs":{}}]},{"type":"codeblock","attrs":{"lang":null},"content":[{"type":"text","text":"Benchmark Mode Cnt Score Error Units\nMyBenchmark.testMethod thrpt 20 775.200 ± 121.410 ops/s\nMyBenchmark.testMethod avgt 20 0.003 ± 0.001 s/op\nMyBenchmark.testMethod sample 15261 0.003 ± 0.001 s/op\nMyBenchmark.testMethod:testMethod·p0.00 sample 0.001 s/op\nMyBenchmark.testMethod:testMethod·p0.50 sample 0.003 s/op\nMyBenchmark.testMethod:testMethod·p0.90 sample 0.003 s/op\nMyBenchmark.testMethod:testMethod·p0.95 sample 0.004 s/op\nMyBenchmark.testMethod:testMethod·p0.99 sample 0.004 s/op\nMyBenchmark.testMethod:testMethod·p0.999 sample 0.007 s/op\nMyBenchmark.testMethod:testMethod·p0.9999 sample 0.014 s/op\nMyBenchmark.testMethod:testMethod·p1.00 sample 0.014 s/op\nMyBenchmark.testMethod ss 20 0.003 ± 0.001 s/op","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"10W條路由(老版本)","attrs":{}}]},{"type":"codeblock","attrs":{"lang":null},"content":[{"type":"text","text":"Benchmark Mode Cnt Score Error Units\nMyBenchmark.testMethod thrpt 20 12.765 ± 0.338 ops/s\nMyBenchmark.testMethod avgt 20 0.159 ± 0.006 s/op\nMyBenchmark.testMethod sample 260 0.153 ± 0.001 s/op\nMyBenchmark.testMethod:testMethod·p0.00 sample 0.147 s/op\nMyBenchmark.testMethod:testMethod·p0.50 sample 0.152 s/op\nMyBenchmark.testMethod:testMethod·p0.90 sample 0.157 s/op\nMyBenchmark.testMethod:testMethod·p0.95 sample 0.159 s/op\nMyBenchmark.testMethod:testMethod·p0.99 sample 0.163 s/op\nMyBenchmark.testMethod:testMethod·p0.999 sample 0.167 s/op\nMyBenchmark.testMethod:testMethod·p0.9999 sample 0.167 s/op\nMyBenchmark.testMethod:testMethod·p1.00 sample 0.167 s/op\nMyBenchmark.testMethod ss 20 0.155 ± 0.002 s/op","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"10W條路由(新版本)","attrs":{}}]},{"type":"codeblock","attrs":{"lang":null},"content":[{"type":"text","text":"Benchmark Mode Cnt Score Error Units\nMyBenchmark.testMethod thrpt 20 774.979 ± 115.501 ops/s\nMyBenchmark.testMethod avgt 20 0.003 ± 0.001 s/op\nMyBenchmark.testMethod sample 15422 0.003 ± 0.001 s/op\nMyBenchmark.testMethod:testMethod·p0.00 sample 0.002 s/op\nMyBenchmark.testMethod:testMethod·p0.50 sample 0.002 s/op\nMyBenchmark.testMethod:testMethod·p0.90 sample 0.004 s/op\nMyBenchmark.testMethod:testMethod·p0.95 sample 0.004 s/op\nMyBenchmark.testMethod:testMethod·p0.99 sample 0.004 s/op\nMyBenchmark.testMethod:testMethod·p0.999 sample 0.005 s/op\nMyBenchmark.testMethod:testMethod·p0.9999 sample 0.011 s/op\nMyBenchmark.testMethod:testMethod·p1.00 sample 0.012 s/op\nMyBenchmark.testMethod ss 20 0.003 ± 0.001 s/op","attrs":{}}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}}]}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章