{"id":2084,"date":"2016-06-05T20:49:03","date_gmt":"2016-06-05T11:49:03","guid":{"rendered":"http:\/\/1bed.allright.life\/?p=2084"},"modified":"2020-04-18T21:33:57","modified_gmt":"2020-04-18T12:33:57","slug":"post-2084","status":"publish","type":"post","link":"https:\/\/1bed.allright.life\/?p=2084","title":{"rendered":"PowerShell \u306e\u4e26\u5217\u51e6\u7406\u3092\u8a66\u3057\u3066\u307f\u305f"},"content":{"rendered":"<h2>\u4e26\u5217\u51e6\u7406\u3092\u8a66\u3059<\/h2>\n<p>\u975e\u540c\u671f\u51e6\u7406\u3088\u308a\u7c21\u5358\u306b\u5c0e\u5165\u3067\u304d\u305d\u3046\u3060\u3063\u305f\u306e\u3067\u3001PowerShell \u3067\u306e\u4e26\u5217\u51e6\u7406\u3092\u8a66\u3057\u3066\u307f\u307e\u3057\u305f<\/p>\n<h3>\u4f8b\u6587\u3067\u306e\u5171\u901a\u90e8\u5206<\/h3>\n<p>3 \u79d2\u30b9\u30ea\u30fc\u30d7\u5f8c\u3001\u5f15\u6570\u3067\u53d7\u3051\u53d6\u3063\u305f\u6587\u5b57\u3092\u8868\u793a\u3057\u307e\u3059<\/p>\n<pre><code class=\"language-powershell\">function Do-Process()\n{\n    param(\n        [string]\n        $text\n    )\n\n    $wait = 3\n    Start-Sleep -Seconds $wait\n    Write-Host &quot;$text, Wait:$wait&quot;\n}<\/code><\/pre>\n<h3>\u540c\u671f\u51e6\u7406(\u901a\u5e38\u306e\u51e6\u7406)<\/h3>\n<p>5 \u56de Do-Process \u3092\u547c\u3073\u51fa\u3059(\u540c\u671f\u51e6\u7406)<\/p>\n<pre><code class=\"language-powershell\">function Test-Sync()\n{\n    foreach ($i in 1..5) {\n        Do-Process &quot;Process ${i}&quot;\n    }\n}\n\n# \u5b9f\u884c\n$time = Measure-Command {\n    Test-Sync\n}<\/code><\/pre>\n<p>\u5b9f\u884c\u7d50\u679c<\/p>\n<pre><code class=\"language-powershell\">Process 1, Wait:3\nProcess 2, Wait:3\nProcess 3, Wait:3\nProcess 4, Wait:3\nProcess 5, Wait:3\n15029.085<\/code><\/pre>\n<p>\u4e88\u5b9a\u901a\u308a 15 \u79d2\u304b\u304b\u3063\u3066\u3044\u308b<\/p>\n<h3>\u4e26\u5217\u51e6\u7406<\/h3>\n<p>5 \u56de Do-Process \u3092\u547c\u3073\u51fa\u3059(\u4e26\u5217\u51e6\u7406)<\/p>\n<pre><code class=\"language-powershell\">Workflow Test-Parallel()\n{\n    foreach -parallel ($i in 1..5) {\n        Do-Process &quot;Process ${i}&quot;\n    }\n}\n\n# \u4e26\u5217\u51e6\u7406\u3067\u5b9f\u884c\n$time = Measure-Command {\n    Test-Parallel\n}\n$time.TotalMilliseconds<\/code><\/pre>\n<p>1\u56de\u76ee\u306e\u5b9f\u884c\u7d50\u679c<\/p>\n<pre><code class=\"language-powershell\">Process 5, Wait:3\nProcess 3, Wait:3\nProcess 4, Wait:3\nProcess 2, Wait:3\nProcess 1, Wait:3\n11181.2299<\/code><\/pre>\n<p>3 \u79d2\u5f37\u306e\u4e88\u5b9a\u3060\u3063\u305f\u304c 11 \u79d2\u3082\u304b\u304b\u3063\u3066\u3044\u308b<\/p>\n<p>2\u56de\u76ee\u306e\u5b9f\u884c<\/p>\n<pre><code class=\"language-powershell\">Process 5, Wait:3\nProcess 4, Wait:3\nProcess 2, Wait:3\nProcess 1, Wait:3\nProcess 3, Wait:3\n3754.6529<\/code><\/pre>\n<p>\u4eca\u5ea6\u306f\u4e88\u5b9a\u901a\u308a\u306e 3 \u79d2\u5f37\u3060\u3063\u305f\u304c\u6700\u521d\u306f\u4f55\u6545\u6642\u9593\u304c\u304b\u304b\u308b\u3093\u3060\u308d\u3046\uff1f<\/p>\n<h2>\u53c2\u8003<\/h2>\n<ul>\n<li>\n<p><a href=\"http:\/\/blogahf.blogspot.jp\/2012\/12\/powershell-30-foreach-parallel.html\">PowerShell 3.0 \u306e ForEach \u2013parallel \u306f\u30de\u30eb\u30c1\u30b9\u30ec\u30c3\u30c9\u3067\u306f\u306a\u3044<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"http:\/\/tech.guitarrapc.com\/entry\/2013\/10\/29\/100946\">PowerShell \u306b\u3088\u308b\u540c\u671f\u51e6\u7406\u3001\u975e\u540c\u671f\u51e6\u7406\u3001\u4e26\u5217\u51e6\u7406 \u3092\u8003\u3048\u3066\u307f\u308b<\/a><\/p>\n<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u4e26\u5217\u51e6\u7406\u3092\u8a66\u3059 \u975e\u540c\u671f\u51e6\u7406\u3088\u308a\u7c21\u5358\u306b\u5c0e\u5165\u3067\u304d\u305d\u3046\u3060\u3063\u305f\u306e\u3067\u3001PowerShell \u3067\u306e\u4e26\u5217\u51e6\u7406\u3092\u8a66\u3057\u3066\u307f\u307e\u3057\u305f \u4f8b\u6587\u3067\u306e\u5171\u901a\u90e8\u5206 3 \u79d2\u30b9\u30ea\u30fc\u30d7\u5f8c\u3001\u5f15\u6570\u3067\u53d7\u3051\u53d6\u3063\u305f\u6587\u5b57\u3092\u8868\u793a\u3057\u307e\u3059 function Do-Process [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[62],"class_list":["post-2084","post","type-post","status-publish","format-standard","hentry","category-program","tag-powershell"],"_links":{"self":[{"href":"https:\/\/1bed.allright.life\/index.php?rest_route=\/wp\/v2\/posts\/2084","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/1bed.allright.life\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/1bed.allright.life\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/1bed.allright.life\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/1bed.allright.life\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2084"}],"version-history":[{"count":4,"href":"https:\/\/1bed.allright.life\/index.php?rest_route=\/wp\/v2\/posts\/2084\/revisions"}],"predecessor-version":[{"id":3156,"href":"https:\/\/1bed.allright.life\/index.php?rest_route=\/wp\/v2\/posts\/2084\/revisions\/3156"}],"wp:attachment":[{"href":"https:\/\/1bed.allright.life\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2084"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/1bed.allright.life\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2084"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/1bed.allright.life\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2084"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}