Ognacの雑感

木漏れ日々

目次

Blog 利用状況

書庫

ギャラリ

意識以上に差があった処理速度

以前, 見えない箇所での無作法は許されるのか? http://blogs.wankuma.com/ognac/archive/2006/07/17/32819.aspx
で IsDateは変だと書いたのですが,ジャンヌさんから, TryParseの件で゜アドバイスを頂き,
気になったので,framework2.0の環境を構築し,速度測定してみた。
  実施してみて,改めて,関心することになった。

環境:プロセッサ x86 Family 15 Model 2 Stepping 7 GenuineIntel ~2394 Mhz
     BIOS バージョン/日付 Phoenix/Award Technologies, LTD 6.00 PG, 2003/04/03
     合計物理メモリ 1,024.00 MB
     バージョン = "5.1.2600.2180 (xpsp_sp2_rtm.040803-2158)"
     VS2005(Professional) で実行。


単位は 1.命令あたりの μ秒を算出してある。 小数点以下3桁で表示

  (OKのみ) は対象データがすべて正しい場合:
        Dim OKのみ() As String = New String() {"2006/12/12", "2007/12/12", "2006/10/10", "2006/02/30"}
  (NGあり) は対象データのなかにNGデータを含めた場合:
        Dim NGあり() As String = New String() {"2006/02/31", "", Nothing, "2006/02/30"}

これを  DateTime.tryparse(str) ,IsDate(str),Convert.ToDateTime(str) で10回実施し,平均をとってみた。
   基準として  10 + 20 の加算式での結果をとり結果は0.004μ秒 となりました.これを基準にした。

●DateTime.tryparse(OKのみ)     8.385μ秒
  VB.DateTime.tryparse(NGあり)     4.123μ秒
●Isdate(OKのみ)          131.333μ秒
  Isdate(NGのみ)           65.087μ秒
●Convert.ToDateTime_OK(OKのみ)10251.863μ秒 : try Catchで処理
  Convert.ToDateTime_OK(NGあり)10417.849μ秒 : try Catchで処理

となった。 興味深い結果である。isDate/TryParseでは, NGがあったほうが,早いのである。
            事前に NGのDataは除外し,OKデータのみで判定している模様。
             ということは,有効なデータの型変換が遅い.(かな?)
Convert.ToDateTime は 非日付の時,例外が発生するので,自前でCatchしたので,異なる結果になった模様。

これにより、

Isdateは tryParseより 15倍遅い.ので原則禁止.
tryparse()の事前に, 明らかに日付を構成しない文字列は弾く.
例外のTry/Catch処理は,とてつもなくコストが高いことがわかる。
 今以上に,例外を期待するコーディングはダメと叫ぼう。

 

                        

投稿日時 : 2006年7月23日 2:05

Feedback

# re: 意識以上に差があった処理速度 2006/07/23 13:17 じゃんぬ

> 興味深い結果である。isDate/TryParseでは, NGがあったほうが,早いのである。

これは、NG だった時点で return されるからでしょうね。
逆に例外処理に頼った場合、NG の方がコストが高くなるのは、
例外のインスタンス生成に手間取るからであり、自明ではあります。

# I read this paragraph completely on the topic of the difference of latest and previous technologies, it's remarkable article. 2019/04/11 3:20 I read this paragraph completely on the topic of t

I read this paragraph completely on the topic of the
difference of latest and previous technologies, it's remarkable article.

# Hi there, just wanted to say, I enjoyed this post. It was practical. Keep on posting! 2019/05/09 22:11 Hi there, just wanted to say, I enjoyed this post.

Hi there, just wanted to say, I enjoyed this post.
It was practical. Keep on posting!

# Hi! I could have sworn I've been to this site before but after browsing through some of the post I realized it's new to me. Nonetheless, I'm definitely happy I found it and I'll be bookmarking and checking back often! 2021/08/31 20:21 Hi! I could have sworn I've been to this site befo

Hi! I could have sworn I've been to this site before but after
browsing through some of the post I realized it's new to me.

Nonetheless, I'm definitely happy I found it and I'll be bookmarking
and checking back often!

# Hi! I could have sworn I've been to this site before but after browsing through some of the post I realized it's new to me. Nonetheless, I'm definitely happy I found it and I'll be bookmarking and checking back often! 2021/08/31 20:22 Hi! I could have sworn I've been to this site befo

Hi! I could have sworn I've been to this site before but after
browsing through some of the post I realized it's new to me.

Nonetheless, I'm definitely happy I found it and I'll be bookmarking
and checking back often!

# Hi! I could have sworn I've been to this site before but after browsing through some of the post I realized it's new to me. Nonetheless, I'm definitely happy I found it and I'll be bookmarking and checking back often! 2021/08/31 20:23 Hi! I could have sworn I've been to this site befo

Hi! I could have sworn I've been to this site before but after
browsing through some of the post I realized it's new to me.

Nonetheless, I'm definitely happy I found it and I'll be bookmarking
and checking back often!

# Hi! I could have sworn I've been to this site before but after browsing through some of the post I realized it's new to me. Nonetheless, I'm definitely happy I found it and I'll be bookmarking and checking back often! 2021/08/31 20:24 Hi! I could have sworn I've been to this site befo

Hi! I could have sworn I've been to this site before but after
browsing through some of the post I realized it's new to me.

Nonetheless, I'm definitely happy I found it and I'll be bookmarking
and checking back often!

# of course like your website however you have to take a look at the spelling on several of your posts. Many of them are rife with spelling problems and I in finding it very bothersome to inform the truth however I'll surely come again again. 2021/09/01 22:08 of course like your website however you have to ta

of course like your website however you have to take a
look at the spelling on several of your posts. Many of them are rife with spelling
problems and I in finding it very bothersome to inform
the truth however I'll surely come again again.

# of course like your website however you have to take a look at the spelling on several of your posts. Many of them are rife with spelling problems and I in finding it very bothersome to inform the truth however I'll surely come again again. 2021/09/01 22:09 of course like your website however you have to ta

of course like your website however you have to take a
look at the spelling on several of your posts. Many of them are rife with spelling
problems and I in finding it very bothersome to inform
the truth however I'll surely come again again.

# of course like your website however you have to take a look at the spelling on several of your posts. Many of them are rife with spelling problems and I in finding it very bothersome to inform the truth however I'll surely come again again. 2021/09/01 22:10 of course like your website however you have to ta

of course like your website however you have to take a
look at the spelling on several of your posts. Many of them are rife with spelling
problems and I in finding it very bothersome to inform
the truth however I'll surely come again again.

# of course like your website however you have to take a look at the spelling on several of your posts. Many of them are rife with spelling problems and I in finding it very bothersome to inform the truth however I'll surely come again again. 2021/09/01 22:11 of course like your website however you have to ta

of course like your website however you have to take a
look at the spelling on several of your posts. Many of them are rife with spelling
problems and I in finding it very bothersome to inform
the truth however I'll surely come again again.

# First off I would like to say great blog! I had a quick question that I'd like to ask if you do not mind. I was interested to find out how you center yourself and clear your thoughts before writing. I have had a tough time clearing my mind in getting my 2021/09/01 23:58 First off I would like to say great blog! I had a

First off I would like to say great blog! I had a quick question that
I'd like to ask if you do not mind. I was interested to find out how you center yourself and clear
your thoughts before writing. I have had a tough time clearing my mind
in getting my thoughts out. I truly do take pleasure in writing but it just
seems like the first 10 to 15 minutes are lost simply just trying to figure out how to begin. Any suggestions or hints?

Thanks!

# First off I would like to say great blog! I had a quick question that I'd like to ask if you do not mind. I was interested to find out how you center yourself and clear your thoughts before writing. I have had a tough time clearing my mind in getting my 2021/09/01 23:59 First off I would like to say great blog! I had a

First off I would like to say great blog! I had a quick question that
I'd like to ask if you do not mind. I was interested to find out how you center yourself and clear
your thoughts before writing. I have had a tough time clearing my mind
in getting my thoughts out. I truly do take pleasure in writing but it just
seems like the first 10 to 15 minutes are lost simply just trying to figure out how to begin. Any suggestions or hints?

Thanks!

# First off I would like to say great blog! I had a quick question that I'd like to ask if you do not mind. I was interested to find out how you center yourself and clear your thoughts before writing. I have had a tough time clearing my mind in getting my 2021/09/02 0:00 First off I would like to say great blog! I had a

First off I would like to say great blog! I had a quick question that
I'd like to ask if you do not mind. I was interested to find out how you center yourself and clear
your thoughts before writing. I have had a tough time clearing my mind
in getting my thoughts out. I truly do take pleasure in writing but it just
seems like the first 10 to 15 minutes are lost simply just trying to figure out how to begin. Any suggestions or hints?

Thanks!

# First off I would like to say great blog! I had a quick question that I'd like to ask if you do not mind. I was interested to find out how you center yourself and clear your thoughts before writing. I have had a tough time clearing my mind in getting my 2021/09/02 0:01 First off I would like to say great blog! I had a

First off I would like to say great blog! I had a quick question that
I'd like to ask if you do not mind. I was interested to find out how you center yourself and clear
your thoughts before writing. I have had a tough time clearing my mind
in getting my thoughts out. I truly do take pleasure in writing but it just
seems like the first 10 to 15 minutes are lost simply just trying to figure out how to begin. Any suggestions or hints?

Thanks!

# I love it when folks get together and share opinions. Great website, stick with it! 2021/09/03 21:36 I love it when folks get together and share opinio

I love it when folks get together and share opinions. Great website, stick with it!

# I love what you guys are up too. This kind of clever work and reporting! Keep up the fantastic works guys I've you guys to our blogroll. quest bars https://www.iherb.com/search?kw=quest%20bars quest bars 2021/09/14 6:15 I love what you guys are up too. This kind of cle

I love what you guys are up too. This kind of clever work and reporting!

Keep up the fantastic works guys I've you guys to our blogroll.
quest bars https://www.iherb.com/search?kw=quest%20bars quest bars

# I love what you guys are up too. This kind of clever work and reporting! Keep up the fantastic works guys I've you guys to our blogroll. quest bars https://www.iherb.com/search?kw=quest%20bars quest bars 2021/09/14 6:16 I love what you guys are up too. This kind of cle

I love what you guys are up too. This kind of clever work and reporting!

Keep up the fantastic works guys I've you guys to our blogroll.
quest bars https://www.iherb.com/search?kw=quest%20bars quest bars

# I love what you guys are up too. This kind of clever work and reporting! Keep up the fantastic works guys I've you guys to our blogroll. quest bars https://www.iherb.com/search?kw=quest%20bars quest bars 2021/09/14 6:17 I love what you guys are up too. This kind of cle

I love what you guys are up too. This kind of clever work and reporting!

Keep up the fantastic works guys I've you guys to our blogroll.
quest bars https://www.iherb.com/search?kw=quest%20bars quest bars

# I love what you guys are up too. This kind of clever work and reporting! Keep up the fantastic works guys I've you guys to our blogroll. quest bars https://www.iherb.com/search?kw=quest%20bars quest bars 2021/09/14 6:18 I love what you guys are up too. This kind of cle

I love what you guys are up too. This kind of clever work and reporting!

Keep up the fantastic works guys I've you guys to our blogroll.
quest bars https://www.iherb.com/search?kw=quest%20bars quest bars

# Hey there just wanted to give you a brief heads up and let you know a few of the pictures aren't loading correctly. I'm not sure why but I think its a linking issue. I've tried it in two different internet browsers and both show the same outcome. 2021/10/25 21:27 Hey there just wanted to give you a brief heads up

Hey there just wanted to give you a brief heads up and
let you know a few of the pictures aren't loading correctly.
I'm not sure why but I think its a linking issue.
I've tried it in two different internet browsers and both
show the same outcome.

# Magnificent site. Lots of useful info here. I am sending it to several pals ans additionally sharing in delicious. And obviously, thanks on your sweat! 2021/11/12 10:58 Magnificent site. Lots of useful info here. I am s

Magnificent site. Lots of useful info here.

I am sending it to several pals ans additionally
sharing in delicious. And obviously, thanks on your sweat!

# My partner and I stumbled over here by a different page and thought I might as well check things out. I like what I see so now i am following you. Look forward to going over your web page repeatedly. 2022/01/08 12:52 My partner and I stumbled over here by a different

My partner and I stumbled over here by a different page and thought I might
as well check things out. I like what I see so now i am following you.
Look forward to going over your web page repeatedly.

# ttgOcrrPjyRWrbZ 2022/04/19 12:59 johnanz

http://imrdsoacha.gov.co/silvitra-120mg-qrms

# Read information now. earch our drug database.
https://edonlinefast.com
Everything information about medication. Cautions. 2023/02/16 22:02 EdPills

Read information now. earch our drug database.
https://edonlinefast.com
Everything information about medication. Cautions.

# purchase doxycycline online - https://doxycyclinesale.pro/# 2023/04/22 4:12 Doxycycline

purchase doxycycline online - https://doxycyclinesale.pro/#

# prednisone 50 mg canada - https://prednisonesale.pro/# 2023/04/22 15:18 Prednisone

prednisone 50 mg canada - https://prednisonesale.pro/#

# buy cytotec online - https://cytotecsale.pro/# 2023/04/29 4:48 Cytotec

buy cytotec online - https://cytotecsale.pro/#

# yeast infection treatment over the counter https://overthecounter.pro/# 2023/05/08 22:54 OtcJikoliuj

yeast infection treatment over the counter https://overthecounter.pro/#

# prednisone 50 mg prices https://prednisonepills.pro/# - prednisone 20mg capsule 2023/06/05 5:25 Prednisone

prednisone 50 mg prices https://prednisonepills.pro/# - prednisone 20mg capsule

# buy cytotec pills online cheap https://cytotec.ink/# - buy cytotec online fast delivery 2023/07/27 1:22 PillsFree

buy cytotec pills online cheap https://cytotec.ink/# - buy cytotec online fast delivery

# online meeting sites 2023/08/09 18:42 WayneGurry

on line free dating: http://datingtopreview.com/# - dating service websites

# cytotec buy online usa 2023/08/27 0:44 Georgejep

https://misoprostol.guru/# п»?cytotec pills online

# acquistare farmaci senza ricetta 2023/09/24 17:54 Archieonelf

http://farmaciaonline.men/# farmaci senza ricetta elenco

# comprare farmaci online all'estero 2023/09/25 16:59 Archieonelf

http://pharmacieenligne.icu/# Pharmacie en ligne France

# paxlovid price 2023/10/24 10:33 LarryNef

http://paxlovid.bid/# paxlovid generic

# buy paxlovid online https://paxlovid.bid/ paxlovid cost without insurance 2023/10/25 23:03 Paxlovid

buy paxlovid online https://paxlovid.bid/ paxlovid cost without insurance

# erection pills online https://edpills.tech/# best pill for ed 2023/12/23 8:16 EdPills

erection pills online https://edpills.tech/# best pill for ed

# buy prednisone 10mg https://prednisone.bid/ generic over the counter prednisone 2023/12/27 10:26 Prednisone

buy prednisone 10mg https://prednisone.bid/ generic over the counter prednisone

# eva elfie izle https://evaelfie.pro/ eva elfie 2024/03/03 5:59 EvaElfia

eva elfie izle https://evaelfie.pro/ eva elfie

# Misoprostol 200 mg buy online https://cytotec.club/ buy cytotec online fast delivery 2024/04/28 2:16 Cytotec

Misoprostol 200 mg buy online https://cytotec.club/ buy cytotec online fast delivery

タイトル
名前
Url
コメント