閲覧総計:5405 (本日:1 昨日:0)
プログラムを作成していると「これ処理が遅いなあ。どこの処理にどれくらいの時間
が掛かっているんだろう?」とコードの処理時間を計測したいニーズが発生します。
コードの処理時間を計測する方法 Stopwatchクラスの使用法を確認したのでメモを
残しておきます。 10/09/04
【参考にしたページ】
http://www.atmarkit.co.jp/fdotnet/dotnettips/412stopwatch/stopwatch.html
開発環境:VWD2008 + Access2003
サーバ:ASP.NET3.5 + Access2003
【実行画面】
【Stopwatch.aspx】
<%@ Page Language="VB" %> <%@ Import Namespace="System" %> <%@ Import Namespace="System.Diagnostics" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <script runat="server"> Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Dim sw As New Stopwatch sw.Start() System.Threading.Thread.Sleep(1000) sw.Stop() ' ミリ秒単位で出力 Dim millisec As Long = sw.ElapsedMilliseconds Label1.Text = millisec ' 出力例:998 ' TimeSpan構造体で書式付き表示 Dim ts As TimeSpan = sw.Elapsed Label2.Text = ts.ToString ' 出力例:00:00:00.9984668 End Sub </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> コード実行時間を計測するStopwatch機能の使用法の確認 10/08/31<br /> ↓参考ページ<br /> <a href="http://www.atmarkit.co.jp/fdotnet/dotnettips/412stopwatch/stopwatch.html"> http://www.atmarkit.co.jp/fdotnet/dotnettips/412stopwatch/stopwatch.html</a><br /> <br /> <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="実行時間計測" /> <br /> <br /> 実行時間(ミリ秒表示):<asp:Label ID="Label1" runat="server" Text="???"></asp:Label> ミリ秒<br /> <br /> 実行時間(時分秒表示):<asp:Label ID="Label2" runat="server" Text="???"></asp:Label> <br /> </div> </form> </body> </html>
【参考にしたページ】
http://www.atmarkit.co.jp/fdotnet/dotnettips/412stopwatch/stopwatch.html
http://www.tiffany-jewelry.net/ will http://www.nike-air-max.com.de/ rely http://www.adidas-superstar.nl/ on http://www.tommy-hilfiger.com.de/ the http://www.basketballshoes.com.co/ holding http://www.pradahandbags.net.co/ to http://www.hermes-outlet.com.co/ go, http://www.thenorth-faces.co.uk/ if http://www.newbalance-outlet.org/ there http://www.louisvuitton-outlet.com.co/ is http://www.ugg-australia.com.de/ any http://www.newbalance-shoes.org/ sign http://www.cheap-raybans.com/ of trouble, but also http://www.burberry-handbagsoutlet.com.co/ possession http://www.cheaprayban.com.co/ of http://www.adidas.org.es/ arms http://www.coachblackfriday.com/ aunt. http://www.hollisterclothingstore.org/ Her http://www.barbour-jacketsoutlet.com/ body http://www.timberlandshoes.net.co/ will http://www.pulseras-pandora.com.es/ always http://www.tommyhilfiger.net.co/ be a http://www.nike-schuhe.com.de/ good http://www.cheapjerseys.com.co/ smell, http://www.guccioutlet-sale.in.net/ grassy http://www.ralphlaurenepolo.com/ taste http://www.p90xworkout.us.com/ of http://www.eyeglassesonline.us.com/ green http://www.the-north-face.ca/ time, http://www.uggs-onsale.net/ even http://www.airjordans.us/ more http://www.mcmsworldwide.com/ than his http://www.uggboots.com.de/ grandmother sandalwood incense http://www.salvatoreferragamo.in.net/ out many http://www.tiffany-andco.com.au/ times. http://www.soft-ballbats.com/ (Read the http://www.replica-handbags.in.net/ article http://www.nike-shoes-canada.ca/ Network: www.sanwen.net)So, I http://www.handbagsoutlet.net.co/ like http://www.christianlouboutinoutlet.net.co/ aunt, http://www.nfl-jersey.us.com/ preferring to http://www.michael-kors-outlet.us.org/ let http://www.nikeskos.dk/ her http://www.chanel-bags.com.co/ hold. http://www.abercrombie-fitchsale.com/ Aunt http://supra.shoesoutlet.us.com/ grandmother http://www.thenorthfacejackets.net.co/ is http://www.cheapjerseys.us.org/ to http://www.yoga-pants.ca/ allow http://www.bottegaveneta-bagsoutlet.com/ a http://www.michael-kors-outlet-online.us.org/ lot http://www.the-northfacejackets.us.com/ of care http://www.mk-outlet.us.com/ of http://www.pandora-charms.org.uk/ me and http://www.burberry2016.co.uk/ coax me http://www.nike-shoesoutlet.us.com/ play.Most http://www.ray-ban-outlet.us.com/ of http://www.asics-outlet.us.com/ the http://www.ralphlaurenoutletonline.in.net/ time http://www.nikefree-run.net/ we http://www.nike-air-max.ca/ were http://www.polooutlets-store.com/ running http://www.supra-shoes.org/ out Feng Wan, http://www.tommy-hilfiger-online-shop.de/ climb http://www.airmax-90.org/ the http://www.oakley-sunglasses.mex.com/ hill http://www.vans-schuhe.com.de/ pick berries, http://www.rosherun.org.uk/ go http://www.longchamp.us.org/ to http://www.hollister-abercrombie.com.se/ the http://www.swarovski-online-shop.de/ stream http://www.the-northface.net.co/ edge http://www.abercrombie-hollister.nl/ scoop tadpoles and grass http://www.longchamp-handbags.us.com/ carp. http://coach.euro-us.net/ I especially http://www.ralphlaurenoutlet.us.com/ like http://www.michael-kors-handbags.us.com/ to http://www.asicsgels.de/ play, http://www.toms-outlets.us.com/ but http://www.outlet-burberry.net.co/ also are http://www.mcmhandbags.com.co/ a http://www.tomsshoes-outlet.us.com/ go http://www.toms--outlet.com.co/ pestering http://www.ugg-boots.us.org/ aunt, http://www.tommy-hilfigeroutlet.com/ in http://www.mcm-bags.in.net/ childhood, http://www.rolex-watch.me.uk/ she used http://www.hollister-clothing.in.net/ to http://www.michaeljordan.com.de/ be http://www.truereligion-outlet.com.co/ my http://www.michael-kors.com.co/ best http://www.michael-kors-taschen.com.de/ friend, http://www.ugg-boots.ca/ even http://www.adidasshoes.top/ though http://www.nike-air-max.us/ she http://www.thejoreseproject.com/ was http://www.louisvuitton.so/ more http://www.jordanrelease-dates.us.com/ than http://www.ferragamo.com.co/ I http://www.oakley-sunglasses-canada.ca/ was http://www.longchamphandbagsoutlet.net/ up http://www.beats-by-dre.com.co/ a http://www.coach-purseoutlet.net/ big http://www.pandorajewelry.top/ slice. http://www.swarovski-australia.com.au/ She http://www.coach-factory.in.net/ often http://www.levisjeans.com.co/ cajole, http://www.cheapoakley-sunglasses.com/ and http://nike.shoesoutlet.us.com/ looked at http://www.hollisters-canada.ca/ me http://www.bcbg-max-azria.ca/ to http://www.ralph-laurenoutlet.ca/ sleep, http://www.rayban-sunglassesoutlet.co.uk/ I http://www.coachoutletstore-online.com.co/ do http://www.coco-chanel.com.de/ not http://www.nikestore.com.de/ want http://www.ugg-uggboots.net/ a http://www.canada-goosesjackets.us.com/ person to sleep, http://www.burberry-outletonlinesale.in.net/ especially http://www.cheap-baseballbats.net/ in http://www.pandora.com.de/ the http://www.uggsoutlet.com.co/ cabin http://www.jimmy-choos.com/ my http://www.raybans.us.org/ own http://airhuarache.shoesoutlet.us.com/ house, http://www.moncler-outlet.us.org/ I http://www.ferragamoshoes.in.net/ will http://www.nike-roshe-run.de/ pull http://www.burberryonlineshop.de/ aunt http://www.oakley-sunglassoutlet.net/ sleeves, http://www.tommy-hilfiger.co.nl/ let http://www.rolexwatchesforsale.us.com/ her http://www.nike-skor.com.se/ tell http://www.chiflatiron.net.co/ me stories http://www.airhuarache.co.uk/ before http://www.abercrombie-fitchs.us.com/ they http://www.hollister.us.org/ agree http://www.tomsoutletonline.net/ to http://www.abercrombie-kids.us.com/ sleep. http://www.pumaonline-shop.de/ Sometimes http://www.adidas-schuhe-online.de/ aunt http://www.hermesbags.jp.net/ tired, http://www.rayban.org.es/ rest will be http://www.weddingdressesuk.org.uk/ lying next http://www.michael-kors-australia.com.au/ to http://www.burberrysoutlet2016.com/ me, http://www.tommy-hilfiger-canada.ca/ but http://www.hollisteronlineshop.com.de/ my http://www.nikestore.us/ time is the http://www.christian--louboutin.in.net/ most mischievous of http://www.converse-shoes.net/ the opportunity, I http://www.polo-ralph-lauren.de/ would http://www.celine-bags.org/ deliberately http://www.ralphslauren-outlet.co.uk/ squeezed http://www.kate-spade.gb.net/ her, http://airmax.shoesoutlet.us.com/ or get http://www.michaelkorsoutletonline-sale.us.com/ up http://www.lululemon-australia.com.au/ reading http://www.tnf-jackets.us.com/ her http://www.louboutin.jp.net/ lashes http://monsterbeats.co-om.com/ beating, but http://www.longchamp-handbagsoutlet.us.com/ also http://northfaceoutlet.co-om.com/ scratching http://www.bottega-veneta.us.com/ her http://www.thenorthface.com.de/ itch, http://www.converse.net.co/ she http://www.michaelkors.co.nl/ will http://www.nike-schoenen.co.nl/ pretend http://www.abercrombieand-fitch.ca/ angry, http://www.swarovskijewelry.com.co/ but http://www.new-balance-schuhe.de/ also http://www.oakleys-sunglasses.us.com/ drum http://www.jimmy-chooshoes.com/ up http://www.swarovski-crystal.us.com/ toot http://www.insanity-workout.us.com/ mouth http://www.barbour-factory.com/ scare http://www.prada-shoes.com.co/ me. http://www.the-northface.com.co/ -- [[ZYF]] &new{2016-03-23 (水) 11:41:54};