{"id":1194,"date":"2012-10-10T19:08:00","date_gmt":"2012-10-10T16:08:00","guid":{"rendered":"http:\/\/unitycoder.com\/blog\/?p=1194"},"modified":"2012-10-22T23:49:14","modified_gmt":"2012-10-22T20:49:14","slug":"how-to-use-stopwatch-in-javascript","status":"publish","type":"post","link":"https:\/\/unitycoder.com\/blog\/2012\/10\/10\/how-to-use-stopwatch-in-javascript\/","title":{"rendered":"How to use Stopwatch in javascript"},"content":{"rendered":"<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1315\" data-permalink=\"https:\/\/unitycoder.com\/blog\/2012\/10\/10\/how-to-use-stopwatch-in-javascript\/stopwatch_unity_ms\/\" data-orig-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/10\/stopwatch_unity_ms.jpg?fit=680%2C484&amp;ssl=1\" data-orig-size=\"680,484\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"stopwatch_unity_ms\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/10\/stopwatch_unity_ms.jpg?fit=680%2C484&amp;ssl=1\" class=\"alignnone size-full wp-image-1315\" title=\"stopwatch_unity_ms\" src=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/10\/stopwatch_unity_ms.jpg?resize=680%2C484\" alt=\"\" width=\"680\" height=\"484\" srcset=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/10\/stopwatch_unity_ms.jpg?w=680&amp;ssl=1 680w, https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/10\/stopwatch_unity_ms.jpg?resize=300%2C213&amp;ssl=1 300w\" sizes=\"auto, (max-width: 680px) 100vw, 680px\" \/><\/p>\n<p>With stopwatch you can check how long some function takes..<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nvar stopwatch:System.Diagnostics.Stopwatch\u00a0 = new System.Diagnostics.Stopwatch();\r\nstopwatch.Start();\r\n\r\n\/\/ your function here..\r\n\r\nstopwatch.Stop();\r\nDebug.Log(&quot;Timer: &quot; + stopwatch.Elapsed);\r\n\/\/Debug.Log(&quot;Timer: &quot; + stopwatch.ElapsedMilliseconds); \/\/ this one gives you the time in ms\r\nstopwatch.Reset();\r\n\r\n<\/pre>\n<p>More info:<br \/>\n<a title=\"http:\/\/msdn.microsoft.com\/en-us\/library\/system.diagnostics.stopwatch.aspx\" href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/system.diagnostics.stopwatch.aspx\" target=\"_blank\">http:\/\/msdn.microsoft.com\/en-us\/library\/system.diagnostics.stopwatch.aspx<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>With stopwatch you can check how long some function takes.. var stopwatch:System.Diagnostics.Stopwatch\u00a0 = new System.Diagnostics.Stopwatch(); stopwatch.Start(); \/\/ your function here.. stopwatch.Stop(); Debug.Log(&quot;Timer: &quot; + stopwatch.Elapsed); \/\/Debug.Log(&quot;Timer: &quot; + stopwatch.ElapsedMilliseconds); \/\/ this one gives you the time in ms stopwatch.Reset(); More info: http:\/\/msdn.microsoft.com\/en-us\/library\/system.diagnostics.stopwatch.aspx<\/p>\n","protected":false},"author":1,"featured_media":1315,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[4,3],"tags":[18,326,328,327],"class_list":["post-1194","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-demos","category-unity3d","tag-javascript","tag-stopwatch","tag-timer","tag-unityscript"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/10\/stopwatch_unity_ms.jpg?fit=680%2C484&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/p1KTaT-jg","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/1194","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/comments?post=1194"}],"version-history":[{"count":5,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/1194\/revisions"}],"predecessor-version":[{"id":1314,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/1194\/revisions\/1314"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/media\/1315"}],"wp:attachment":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/media?parent=1194"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/categories?post=1194"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/tags?post=1194"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}