{"id":3047,"date":"2022-03-29T15:08:56","date_gmt":"2022-03-29T06:08:56","guid":{"rendered":"http:\/\/anada.cloudfree.jp\/?p=3047"},"modified":"2022-03-29T15:08:56","modified_gmt":"2022-03-29T06:08:56","slug":"stringbuilder%e3%81%a3%e3%81%a6%e3%81%a9%e3%81%86%e3%82%88%ef%bc%9f","status":"publish","type":"post","link":"http:\/\/anada.cloudfree.jp\/?p=3047","title":{"rendered":"StringBuilder\u3063\u3066\u3069\u3046\u3088\uff1f"},"content":{"rendered":"<p>StringBuilder\u306e\u52b9\u679c\u3063\u3066\u3069\u3046\u306a\u306e\u304b\uff1f\u3068\u3044\u3046\u3068\u3053\u308d\u306b\u7591\u554f\u3092\u6301\u3063\u305f\u306e\u3067\u3001\u8abf\u3079\u3066\u307f\u308b\u3053\u3068\u306b\u3057\u305f\u3002<\/p>\n<p>\u2605 <a href=\"https:\/\/zenn.dev\/taiga533\/articles\/43fc599088bbbee39707\" rel=\"noopener\" target=\"_blank\">Java\u306e\u6587\u5b57\u5217\u7d50\u5408\u306fStringBuilder\u3067\u3044\u3044\u306e\u304b<\/a><\/p>\n<p>\u7d50\u8ad6\u7684\u306b\u306f\u3001<\/p>\n<blockquote><p>\n\u30fb\u8907\u6570\u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8\u3067<br \/>\n\u30fb\u7d50\u5408\u3055\u308c\u308b\u5074\u306e\u6587\u5b57\u5217\u3092\u8907\u6570\u30b9\u30ec\u30c3\u30c9\u3067\u5171\u6709\u3057\u306a\u3044\u5834\u5408\u306f<br \/>\n\u30e1\u30e2\u30ea\u30a2\u30ed\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u56de\u6570\u304c\u5c11\u306a\u3044StringBuilder\u304c\u4e00\u756a\u9ad8\u901f\u3067\u6587\u5b57\u5217\u7d50\u5408\u3067\u304d\u308b\n<\/p><\/blockquote>\n<p>\u306a\u306e\u3060\u304c\u3001\u3069\u306e\u3088\u3046\u306a\u51e6\u7406\u306b\u306a\u3063\u3066\u3044\u308b\u306e\u3067\u3053\u3046\u306a\u308b\uff01\u3068\u3044\u3046\u306e\u304c\u66f8\u304b\u308c\u3066\u3044\u3066\u3001\u975e\u5e38\u306b\u53c2\u8003\u306b\u306a\u3063\u305f\u3002<\/p>\n<p>\u30b9\u30ec\u30c3\u30c9\u3092\u4f7f\u3063\u305f\u3068\u304d\u306f\u4e0d\u5177\u5408\u304c\u8d77\u304d\u308b\u3068\u3044\u3046\u306e\u306f\u3001\u4ee5\u4e0b\u306e\u30da\u30fc\u30b8\u306b\u66f8\u3044\u3066\u3042\u308b\u3002<\/p>\n<p>\u2605 <a href=\"http:\/\/www.code-magagine.com\/?p=2022\" rel=\"noopener\" target=\"_blank\">\u3010Java\u3011+\u6f14\u7b97\u5b50\u3001StringBuilder\u3001StringBuffer\u306e\u9055\u3044\uff08\u5b9f\u969b\u306b\u6e2c\u3063\u3066\u307f\u305f\u3002\uff09<\/a><\/p>\n<p>StringBuilder\u3068StringBuffer\u306e\u4f7f\u3044\u5206\u3051\u306b\u3064\u3044\u3066\u3082\u66f8\u3044\u3066\u3042\u308b\u306e\u3067\u3001\u3053\u308c\u3082\u53c2\u8003\u306b\u3002<\/p>\n<p>\u4ee5\u4e0b\u306fVB(.NET)\u306eStringBuilder\u306b\u3064\u3044\u3066\u306e\u8a18\u8f09\u3002<\/p>\n<p>\u2605 <a href=\"https:\/\/mseeeen.msen.jp\/when-to-use-stringbuilder-and-its-benefits\/\" rel=\"noopener\" target=\"_blank\">Visual Basic \u3067 StringBuilder \u3092\u4f7f\u3046\u3079\u304d\u5834\u5408\u3068\u305d\u306e\u5229\u70b9<\/a><\/p>\n<p>\u3053\u3061\u3089\u3082Java\u3068\u540c\u3058\u3088\u3046\u306a\u8a71\u3002\uff08SE2\u5e74\u76ee\u3067\u3053\u306e\u8a18\u8f09\u306f\u51c4\u3044\u306a\u3041\u3002\u3046\u3061\u306e\u793e\u54e1\u306b\u3082\u3053\u3046\u3044\u3046\u4eba\u6b32\u3057\u3044\u3002\uff09<\/p>\n<p>\u4f7f\u3044\u65b9\u306b\u3064\u3044\u3066\u306f\u3001<\/p>\n<p>\u2605 <a href=\"https:\/\/qiita.com\/sugaryo\/items\/109927292eda6410137b\" rel=\"noopener\" target=\"_blank\">\u610f\u5916\u3068\u77e5\u3089\u308c\u3066\u306a\u3044StringBuilder\u306b\u95a2\u3059\u308b\u521d\u6b69\u7684\u306aTips\u3010Java\u30fbC#\u3011<\/a><\/p>\n<p>\u306a\u3093\u304b\u3001\u3069\u3046\u3067\u3057\u3087\u3046\u3002<br \/>\n\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u30b3\u30ed\u30b3\u30ed\u5909\u3048\u305f\u304f\u306a\u3044\u306a\u3041\u3068\u601d\u3063\u3066\u3044\u308b\u306e\u3067\u3001\u3053\u3046\u3044\u3046\u306e\u306f\u3042\u308a\u304c\u305f\u3044\u3002<\/p>\n<p>\u304c\u3001\u5c11\u3057\u5f85\u3066\uff01<\/p>\n<p><big>\u7537\uff08\u304b\u3069\u3046\u304b\u77e5\u3089\u3093\u304c\uff09\u304c\u3059\u306a\u308b\u6642\u9593\u8a08\u6e2c\u3068\u3044\u3075\u3082\u306e\u3092\u5973\u3082\u3057\u3066\u307f\u3080\u3068\u3066\u3059\u308b\u306a\u308a\u30fb\u30fb\u30fb<\/big><\/p>\n<p>VC#(.NET Framework4.8)\u3067\u3084\u3063\u3066\u307f\u305f\u3002<br \/>\n<1> Length=0\u3067\u30af\u30ea\u30a2\u3059\u308b<br \/>\n<2> \u65b0\u305f\u306a\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u4f5c\u308b<br \/>\n<3> Clear\u3092\u4f7f\u3046(C#\u306fClear\u30e1\u30bd\u30c3\u30c9\u304c\u3042\u308b)<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n        static void Main(string&#x5B;] args) {\r\n            var sw = new System.Diagnostics.Stopwatch();\r\n\r\n            \/\/ &lt;1&gt;\r\n            for (int j = 0; j &lt; 10; j++) {\r\n                sw.Start();\r\n                StringBuilder sb1 = new StringBuilder(&quot;&quot;);\r\n                for (int i = 0; i &lt; 999999; i++) {\r\n                    sb1.Length = 0;\r\n                    sb1.Append(i.ToString());\r\n                }\r\n                sw.Stop();\r\n                Console.WriteLine($&quot;1)\u3000{sw.ElapsedMilliseconds}ms&quot;);\r\n            }\r\n\r\n            \/\/ &lt;2&gt;\r\n            for (int j=0;j&lt;10;j++) {\r\n                sw.Restart();\r\n                for (int i = 0; i &lt; 999999; i++) {\r\n                    StringBuilder sb2 = new StringBuilder(&quot;&quot;);\r\n                    sb2.Append(i.ToString());\r\n                }\r\n                sw.Stop();\r\n                Console.WriteLine($&quot;2)\u3000{sw.ElapsedMilliseconds}ms&quot;);\r\n            }\r\n\r\n            \/\/ &lt;3&gt;\r\n            StringBuilder sb3 = new StringBuilder(&quot;&quot;);\r\n            for (int j = 0; j &lt; 10; j++) {\r\n                sw.Restart();\r\n                for (int i = 0; i &lt; 999999; i++) {\r\n                    sb3.Clear();\r\n                    sb3.Append(i.ToString());\r\n                }\r\n                sw.Stop();\r\n                Console.WriteLine($&quot;3)\u3000{sw.ElapsedMilliseconds}ms&quot;);\r\n            }\r\n        }\r\n<\/pre>\n<p>\u7d50\u679c\u767a\u8868\uff01<\/p>\n<table>\n<tr>\n<th><1> Length=0\u3067\u30af\u30ea\u30a2\u3059\u308b<\/th>\n<th><2> \u65b0\u305f\u306a\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u4f5c\u308b<\/th>\n<th><3> Clear\u3092\u4f7f\u3046<\/td>\n<\/tr>\n<tr>\n<td>1)\u3000693ms <\/td>\n<td>2)\u30001440ms<\/td>\n<td>3)\u3000583ms <\/td>\n<\/tr>\n<tr>\n<td>1)\u30001303ms<\/td>\n<td>2)\u30001495ms<\/td>\n<td>3)\u3000503ms <\/td>\n<\/tr>\n<tr>\n<td>1)\u30002398ms<\/td>\n<td>2)\u30001455ms<\/td>\n<td>3)\u3000472ms <\/td>\n<\/tr>\n<tr>\n<td>1)\u30003421ms<\/td>\n<td>2)\u30001401ms<\/td>\n<td>3)\u3000514ms <\/td>\n<\/tr>\n<tr>\n<td>1)\u30004656ms<\/td>\n<td>2)\u3000784ms <\/td>\n<td>3)\u3000520ms <\/td>\n<\/tr>\n<tr>\n<td>1)\u30005780ms<\/td>\n<td>2)\u3000692ms <\/td>\n<td>3)\u3000500ms <\/td>\n<\/tr>\n<tr>\n<td>1)\u30006798ms<\/td>\n<td>2)\u3000580ms <\/td>\n<td>3)\u3000498ms <\/td>\n<\/tr>\n<tr>\n<td>1)\u30007786ms<\/td>\n<td>2)\u3000599ms <\/td>\n<td>3)\u3000519ms <\/td>\n<\/tr>\n<tr>\n<td>1)\u30008868ms<\/td>\n<td>2)\u3000553ms <\/td>\n<td>3)\u3000485ms <\/td>\n<\/tr>\n<tr>\n<td>1)\u30009937ms<\/td>\n<td>2)\u3000643ms <\/td>\n<td>3)\u3000469ms <\/td>\n<\/tr>\n<\/table>\n<p><1> Length=0\u3067\u30af\u30ea\u30a2\u3060\u3068\u3001\u51e6\u7406\u901f\u5ea6\u304c\u3069\u3093\u3069\u3093\u4e0a\u304c\u3063\u3066\u3044\u304f\u306e\u3067\u3001\u5acc\u306a\u611f\u3058\u3002<br \/>\n<2> \u65b0\u305f\u306a\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u4f5c\u308b\u306f\u3001<1>\u3088\u308a\u901f\u304f\u3066<3>\u3068\u540c\u7b49\u304b\u3082\u3057\u304f\u306f\u9045\u3044\u30ec\u30d9\u30eb\u3002<br \/>\n<3> Clear\u3092\u4f7f\u3046\u306e\u304c\u4e00\u756a\u30b3\u30f3\u30b9\u30bf\u30f3\u30c8\u306b\u901f\u3044\u3002<\/p>\n<p>Java\u306f\u8a66\u3057\u3066\u3044\u306a\u3044\u306e\u3067\u7533\u3057\u8a33\u306a\u3044\u306e\u3060\u304c\u3001VC#\u306a\u3089\u3070\u3001\u7528\u610f\u3055\u308c\u3066\u3044\u308bClear\u30e1\u30bd\u30c3\u30c9\u3092\u5229\u7528\u3057\u305f\u307b\u3046\u304c\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u6bce\u5ea6\u4f5c\u308b\u3088\u308a\u306f\u901f\u3044\u3068\u3044\u3046\u3053\u3068\u306b\u306a\u308b\u3002<\/p>\n<p>\u8272\u3005\u8abf\u3079\u3066\u307f\u308b\u3082\u306e\u3060\u3001\u3046\u3093\u3002<br \/>\n\u300c\u7121\u77e5\u306e\u77e5\u300d\u3068\u3044\u3046\u306e\u306f\u5927\u4e8b\u3060\u306a\u3041\u3068\u601d\u3046\u5348\u5f8c\u306e\u3072\u3068\u6642\u3067\u3042\u3063\u305f\u30fb\u30fb\u30fb<\/p>\n","protected":false},"excerpt":{"rendered":"<p>StringBuilder\u306e\u52b9\u679c\u3063\u3066\u3069\u3046\u306a\u306e\u304b\uff1f\u3068\u3044\u3046\u3068\u3053\u308d\u306b\u7591\u554f\u3092\u6301\u3063\u305f\u306e\u3067\u3001\u8abf\u3079\u3066\u307f\u308b\u3053\u3068\u306b\u3057\u305f\u3002 \u2605 Java\u306e\u6587\u5b57\u5217\u7d50\u5408\u306fStringBuilder\u3067\u3044\u3044\u306e\u304b \u7d50\u8ad6\u7684\u306b\u306f\u3001 \u30fb\u8907\u6570\u30b9\u30c6\u30fc\u30c8\u30e1\u30f3\u30c8\u3067 \u30fb\u7d50\u5408\u3055\u308c\u308b\u5074 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,8],"tags":[],"class_list":["post-3047","post","type-post","status-publish","format-standard","hentry","category-excelvba","category-java"],"_links":{"self":[{"href":"http:\/\/anada.cloudfree.jp\/index.php?rest_route=\/wp\/v2\/posts\/3047","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/anada.cloudfree.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/anada.cloudfree.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/anada.cloudfree.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/anada.cloudfree.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3047"}],"version-history":[{"count":8,"href":"http:\/\/anada.cloudfree.jp\/index.php?rest_route=\/wp\/v2\/posts\/3047\/revisions"}],"predecessor-version":[{"id":3055,"href":"http:\/\/anada.cloudfree.jp\/index.php?rest_route=\/wp\/v2\/posts\/3047\/revisions\/3055"}],"wp:attachment":[{"href":"http:\/\/anada.cloudfree.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3047"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/anada.cloudfree.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3047"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/anada.cloudfree.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3047"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}