﻿
{"id":2583,"date":"2014-03-27T18:49:05","date_gmt":"2014-03-27T18:49:05","guid":{"rendered":"http:\/\/www.gencayyildiz.com\/blog\/?p=2583"},"modified":"2014-03-27T18:49:05","modified_gmt":"2014-03-27T18:49:05","slug":"c-stopwatch-sinifiyla-kod-calisma-suresini-bulma","status":"publish","type":"post","link":"https:\/\/www.gencayyildiz.com\/blog\/c-stopwatch-sinifiyla-kod-calisma-suresini-bulma\/","title":{"rendered":"C#- Stopwatch S\u0131n\u0131f\u0131yla Kod \u00c7al\u0131\u015fma S\u00fcresini Bulma"},"content":{"rendered":"<div id=\"fb-root\"><\/div>\n<p>C# ile geli\u015ftirilen projelerde kodlar\u0131n ne kadar s\u00fcrede \u00e7al\u0131\u015ft\u0131\u011f\u0131n\u0131 \u00f6\u011frenmek biz yaz\u0131l\u0131mc\u0131lar i\u00e7in baz\u0131 durumlarda \u00f6nemli bir bilgi olabiliyor.Performans \u00f6l\u00e7\u00fcm i\u015flemleri ya da kod ak\u0131\u015f\u0131n\u0131 hesaplay\u0131p zamanlay\u0131c\u0131lar olu\u015fturmak gibi i\u015flemlerde olduk\u00e7a \u00f6nemli olan kod \u00e7al\u0131\u015fma s\u00fcreleri \u015fimdi sizlere g\u00f6sterece\u011fim y\u00f6ntemle olduk\u00e7a kolay ve sade bir yap\u0131ya sahiptir.<\/p>\n<p>&#8220;<span style=\"color: #ff6600;\">System.Diagnostics<\/span>&#8221; k\u00fct\u00fcphanesinde bulunan &#8220;<span style=\"color: #99cc00;\">Stopwatch<\/span>&#8221; s\u0131n\u0131f\u0131yla kodlar\u0131m\u0131z\u0131n \u00e7al\u0131\u015fma s\u00fcrelerini h\u0131zl\u0131 bir \u015fekilde bulup, istedi\u011fimiz formatta de\u011ferlendirebiliyoruz.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n            Stopwatch SureHesapla = new Stopwatch();\r\n\r\n            SureHesapla.Start();\r\n\r\n            Thread.Sleep(9000);\r\n\r\n            SureHesapla.Stop();\r\n\r\n            TimeSpan HesaplananZaman = SureHesapla.Elapsed;\r\n            string Sonuc = String.Format(&quot;{0:00}:{1:00}:{2:00}.{3:00}&quot;,\r\n            HesaplananZaman.Hours, HesaplananZaman.Minutes, HesaplananZaman.Seconds, HesaplananZaman.Milliseconds \/ 10);\r\n            MessageBox.Show(Sonuc);\r\n<\/pre>\n<p>Yukar\u0131daki kod blo\u011funu incelerseniz e\u011fer &#8220;Stopwatch&#8221; nesnemiz sayesinde kod s\u00fcresi hesaplama kontrol mekanizmas\u0131n\u0131 &#8220;Start&#8221; metoduyla ba\u015flatt\u0131p, &#8220;Stop&#8221; metoduyla da kontrol mekanizmas\u0131n\u0131 durduruyoruz.Bu mekanizma aras\u0131na al\u0131nan kodlar\u0131n s\u00fcreleri hesaplan\u0131p &#8220;TimeSpan&#8221; tipinde mikrosaniyesine kadar veriyi elde edebiliyoruz.\u00d6rne\u011fimizde &#8220;Thread.Sleep(9000)&#8221; kodunun \u00e7al\u0131\u015fma s\u00fcresini hesaplayaca\u011f\u0131z.Hepimiz biliyoruz ki bu metod program ak\u0131\u015f\u0131n\u0131 dokuz saniye durduracakt\u0131r.Haliyle bu kodun \u00e7al\u0131\u015fmas\u0131 dokuz saniye s\u00fcrece\u011fi i\u00e7in \u00e7al\u0131\u015fma s\u00fcremiz teknik olarak 9 ya da 9 saniye ye yak\u0131n bir de\u011fer olacakt\u0131r.<\/p>\n<p>Yukar\u0131daki kodu derleyip \u00e7al\u0131\u015ft\u0131rd\u0131\u011f\u0131m\u0131z zaman program\u0131n sonu\u00e7 \u00e7\u0131kt\u0131s\u0131 a\u015fa\u011f\u0131daki gibi olacakt\u0131r.<br \/>\n<a href=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2014\/03\/KodCalismaSuresi.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2014\/03\/KodCalismaSuresi.png\" alt=\"KodCalismaSuresi\" width=\"138\" height=\"115\" class=\"aligncenter size-full wp-image-2584\" \/><\/a><\/p>\n<p>Sonraki yaz\u0131lar\u0131mda g\u00f6r\u00fc\u015fmek \u00fczere&#8230;<br \/>\n\u0130yi \u00e7al\u0131\u015fmalar dilerim&#8230;<\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>C# ile geli\u015ftirilen projelerde kodlar\u0131n ne kadar s\u00fcrede \u00e7al\u0131\u015ft\u0131\u011f\u0131n\u0131 \u00f6\u011frenmek biz yaz\u0131l\u0131mc\u0131lar i\u00e7in baz\u0131 durumlarda \u00f6nemli bir bilgi olabiliyor.Performans \u00f6l\u00e7\u00fcm i\u015flemleri ya da kod ak\u0131\u015f\u0131n\u0131 hesaplay\u0131p zamanlay\u0131c\u0131lar olu\u015fturmak gibi i\u015flemlerde olduk\u00e7a \u00f6nemli olan kod&#46;&#46;&#46;<!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[27,580],"class_list":["post-2583","post","type-post","status-publish","format-standard","hentry","category-c-sharp-c","tag-c","tag-stopwatch"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts\/2583","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/comments?post=2583"}],"version-history":[{"count":0,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts\/2583\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/media?parent=2583"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/categories?post=2583"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/tags?post=2583"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}