{"id":123508,"date":"2024-07-07T10:00:30","date_gmt":"2024-07-07T01:00:30","guid":{"rendered":"https:\/\/softantenna.com\/blog\/?p=123508"},"modified":"2024-07-07T08:09:45","modified_gmt":"2024-07-06T23:09:45","slug":"windows-time-command","status":"publish","type":"post","link":"https:\/\/softantenna.com\/blog\/windows-time-command\/","title":{"rendered":"Windows\u3067\u30b3\u30de\u30f3\u30c9\u306e\u5b9f\u884c\u6642\u9593\u3092\u8a08\u6e2c\u3059\u308b\u65b9\u6cd5"},"content":{"rendered":"<p><img decoding=\"async\" style=\"display:block; margin-left:auto; margin-right:auto;\" src=\"https:\/\/softantenna.com\/blog\/wp-content\/uploads\/2024\/07\/s_20240704_202124.jpg\" alt=\"S 20240704 202124\" title=\"s_20240704_202124.jpg\" border=\"0\" width=\"1249\" height=\"703\" \/><\/p>\n<p>Linux\u3084macOS\u3067\u306f<code>time<\/code>\u30b3\u30de\u30f3\u30c9\u3092\u4f7f\u7528\u3057\u3066\u30b3\u30de\u30f3\u30c9\u306e\u5b9f\u884c\u6642\u9593\u3092\u8a08\u6e2c\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>Windows 11\u3084Windows 10\u306a\u3069Windows\u7cfb\u306eOS\u306b\u306ftime\u30b3\u30de\u30f3\u30c9\u304c\u642d\u8f09\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u304c\u3001\u304b\u308f\u308a\u306b\u3069\u306e\u3088\u3046\u306a\u65b9\u6cd5\u3092\u4f7f\u3048\u3070\u3088\u3044\u306e\u3067\u3057\u3087\u3046\u304b\u3002<\/p>\n<p>\u4ee5\u4e0b\u3001Windows 11\u3084Windows 10\u3067\u30b3\u30de\u30f3\u30c9\u306e\u5b9f\u884c\u6642\u9593\u3092\u8a08\u6e2c\u3059\u308b\u65b9\u6cd5\u3092\u8aac\u660e\u3057\u307e\u3059(<a href=\"https:\/\/stackoverflow.com\/questions\/673523\/how-do-i-measure-execution-time-of-a-command-on-the-windows-command-line\">Stack Overflow<\/a>\u306e\u60c5\u5831\u3092\u53c2\u8003\u306b\u3057\u307e\u3057\u305f)\u3002<\/p>\n<h2>PowerShell\u3092\u4f7f\u3046\u306e\u304c\u7c21\u5358<\/h2>\n<p>Windows\u7cfbOS\u3067\u30b3\u30de\u30f3\u30c9\u306e\u5b9f\u884c\u6642\u9593\u3092\u6e2c\u5b9a\u3059\u308b\u306b\u306f\u3001PowerShell\u3092\u5229\u7528\u3059\u308b\u306e\u304c\u7c21\u5358\u3067\u3059\u3002<\/p>\n<p>PowerShell\u3092\u8d77\u52d5\u3057\u3001<code>Measure-Command { \u30b3\u30de\u30f3\u30c9 }<\/code>\u3092\u5b9f\u884c\u3059\u308b\u3053\u3068\u3067\u30b3\u30de\u30f3\u30c9\u306e\u5b9f\u884c\u6642\u9593\u3092\u8a08\u6e2c\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u4f8b\u3048\u3070\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n<pre>\r\nPS C:\\Users\\sora> Measure-Command {echo hi}\r\n\r\n\r\nDays              : 0\r\nHours             : 0\r\nMinutes           : 0\r\nSeconds           : 0\r\nMilliseconds      : 0\r\nTicks             : 5236\r\nTotalDays         : 6.06018518518518E-09\r\nTotalHours        : 1.45444444444444E-07\r\nTotalMinutes      : 8.72666666666667E-06\r\nTotalSeconds      : 0.0005236\r\nTotalMilliseconds : 0.5236\r\n<\/pre>\n<p>\u3053\u306e\u307e\u307e\u3067\u306f\u30b3\u30de\u30f3\u30c9\u306e\u51fa\u529b\u304c\u6d88\u3048\u3066\u3057\u307e\u3044\u307e\u3059\u3002<code>Measure-Command { \u30b3\u30de\u30f3\u30c9 | Out-Default}<\/code>\u3068\u5b9f\u884c\u3059\u308b\u3068\u30b3\u30de\u30f3\u30c9\u306e\u51fa\u529b\u304c\u5f97\u3089\u308c\u307e\u3059\u3002<\/p>\n<pre>\r\nPS C:\\Users\\sora> Measure-Command {echo hi | Out-Default}\r\nhi\r\n\r\n\r\nDays              : 0\r\nHours             : 0\r\nMinutes           : 0\r\nSeconds           : 0\r\nMilliseconds      : 0\r\nTicks             : 8078\r\nTotalDays         : 9.34953703703704E-09\r\nTotalHours        : 2.24388888888889E-07\r\nTotalMinutes      : 1.34633333333333E-05\r\nTotalSeconds      : 0.0008078\r\nTotalMilliseconds : 0.8078\r\n<\/pre>\n<p>\u5b9f\u884c\u6642\u9593\u3092\u308f\u304b\u308a\u3084\u3059\u304f\u8868\u793a\u3059\u308b\u306b\u306f<code>(Measure-Command { \u30b3\u30de\u30f3\u30c9 | Out-Default}).ToString()<\/code>\u3068\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n<pre>\r\nPS C:\\Users\\sora> (Measure-Command {echo hi | Out-Default}).ToString()\r\nhi\r\n00:00:00.0009268\r\n<\/pre>\n<p><img decoding=\"async\" style=\"display:block; margin-left:auto; margin-right:auto;\" src=\"https:\/\/softantenna.com\/blog\/wp-content\/uploads\/2024\/07\/s_20240704_202801.jpg\" alt=\"S 20240704 202801\" title=\"s_20240704_202801.jpg\" border=\"0\" width=\"1249\" height=\"703\" \/><\/p>\n<h2>\u30b3\u30de\u30f3\u30c9\u30d7\u30ed\u30f3\u30d7\u30c8\u3067\u306f\u30d0\u30c3\u30c1\u30d5\u30a1\u30a4\u30eb\u304c\u5fc5\u8981<\/h2>\n<p>PowerShell\u3092\u4f7f\u308f\u306a\u3044\u5834\u5408\u306f\u30d0\u30c3\u30c1\u30d5\u30a1\u30a4\u30eb\u306a\u3069\u3092\u5225\u9014\u6e96\u5099\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u3088\u3046\u3067\u3059\u3002\u4f8b\u3048\u3070\u4ee5\u4e0b\u306e\u5185\u5bb9\u3092<code>timecmd.bat<\/code>\u3068\u3057\u3066\u4fdd\u5b58\u3057\u307e\u3059\u3002<\/p>\n<pre>\r\n@echo off\r\n@setlocal\r\n\r\nset start=%time%\r\n\r\n:: Runs your command\r\ncmd \/c %*\r\n\r\nset end=%time%\r\nset options=\"tokens=1-4 delims=:.,\"\r\nfor \/f %options% %%a in (\"%start%\") do set start_h=%%a&set \/a start_m=100%%b %% 100&set \/a start_s=100%%c %% 100&set \/a start_ms=100%%d %% 100\r\nfor \/f %options% %%a in (\"%end%\") do set end_h=%%a&set \/a end_m=100%%b %% 100&set \/a end_s=100%%c %% 100&set \/a end_ms=100%%d %% 100\r\n\r\nset \/a hours=%end_h%-%start_h%\r\nset \/a mins=%end_m%-%start_m%\r\nset \/a secs=%end_s%-%start_s%\r\nset \/a ms=%end_ms%-%start_ms%\r\nif %ms% lss 0 set \/a secs = %secs% - 1 & set \/a ms = 100%ms%\r\nif %secs% lss 0 set \/a mins = %mins% - 1 & set \/a secs = 60%secs%\r\nif %mins% lss 0 set \/a hours = %hours% - 1 & set \/a mins = 60%mins%\r\nif %hours% lss 0 set \/a hours = 24%hours%\r\nif 1%ms% lss 100 set ms=0%ms%\r\n\r\n:: Mission accomplished\r\nset \/a totalsecs = %hours%*3600 + %mins%*60 + %secs%\r\necho command took %hours%:%mins%:%secs%.%ms% (%totalsecs%.%ms%s total)\r\n<\/pre>\n<p>\u3053\u306e\u30d0\u30c3\u30c1\u30d5\u30a1\u30a4\u30eb\u3092\u5229\u7528\u3057\u3001<code>timecmd \u30b3\u30de\u30f3\u30c9<\/code>\u3068\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n<pre>\r\nC:\\opt\\local\\bin>timecmd echo hi\r\nhi\r\ncommand took 0:0:0.03 (0.03s total)\r\n<\/pre>\n<p>\u305d\u306e\u4ed6\u3001\u73fe\u5728\u306fMicrosoft\u306e\u30b5\u30fc\u30d0\u30fc\u304b\u3089\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3067\u304d\u306a\u3044(archive.org\u304b\u3089\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3067\u304d\u308b)\u3001<a href=\"http:\/\/web.archive.org\/web\/20150327014146\/http:\/\/www.microsoft.com\/en-us\/download\/details.aspx?id=17657\">Windows Server 2003 Resource Kit Tools<\/a>\u306b\u542b\u307e\u308c\u308btimeit.exe\u3092\u5229\u7528\u3059\u308b\u65b9\u6cd5\u3082\u3042\u308b\u3088\u3046\u3067\u3059\u3002\u3053\u3061\u3089\u306f\u672a\u78ba\u8a8d\u3067\u3059\u3002<\/p>\n<h2>\u307e\u3068\u3081<\/h2>\n<p>Windows 11\u3084Windows 10\u3067\u30b3\u30de\u30f3\u30c9\u306e\u5b9f\u884c\u6642\u9593\u3092\u8a08\u6e2c\u3059\u308b\u65b9\u6cd5\u3092\u8aac\u660e\u3057\u307e\u3057\u305f\u3002PowerShell\u306b\u62b5\u6297\u304c\u306a\u3051\u308c\u3070Measure-Command\u3092\u4f7f\u3046\u65b9\u6cd5\u304c\u7c21\u5358\u3060\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Linux\u3084macOS\u3067\u306ftime\u30b3\u30de\u30f3\u30c9\u3092\u4f7f\u7528\u3057\u3066\u30b3\u30de\u30f3\u30c9\u306e\u5b9f\u884c\u6642\u9593\u3092\u8a08\u6e2c\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002 Windows 11\u3084Windows 10\u306a\u3069Windows\u7cfb\u306eOS\u306b\u306ftime\u30b3\u30de\u30f3\u30c9\u304c\u642d\u8f09\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u304c\u3001\u304b\u308f\u308a\u306b\u3069 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":123571,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"swell_btn_cv_data":"","footnotes":""},"categories":[2047],"tags":[3298,2701,4387],"class_list":["post-123508","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tips","tag-windows","tag-windows10","tag-windows11"],"_links":{"self":[{"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/posts\/123508","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/comments?post=123508"}],"version-history":[{"count":0,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/posts\/123508\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/media\/123571"}],"wp:attachment":[{"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/media?parent=123508"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/categories?post=123508"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/tags?post=123508"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}