実際のアイテム数をカウントする3つの方法に大きな違いはありますか?ラケットで真を検出する3つの方法の違い
これらはすべて同じ結果をもたらしますが、特定のものを選択する必要がある理由は何か?
編集:時間関数を使用して、以下の結果が@ ChrisJester・ヤングと@Sylwesterによって回答から3つの上記機能及び2それぞれで得られる:
したがって"---------- counttrue ------------"
cpu time: 751 real time: 751 gc time: 16
"---------- counttrue2 ------------"
cpu time: 946 real time: 947 gc time: 10
"---------- counttrue3 ------------"
cpu time: 456 real time: 457 gc time: 8
"---------- counttrue_chris1 ------------"
cpu time: 726 real time: 727 gc time: 9
"---------- counttrue_chris2 ------------"
cpu time: 595 real time: 595 gc time: 8
"---------- counttrue_sylwester1 ------------"
cpu time: 543 real time: 544 gc time: 7
"---------- counttrue_sylwester2 ------------"
cpu time: 515 real time: 515 gc time: 7
、「カウントラムダ」法であります最速
私はラムダが(私に)読むのが最も簡単なので、ラムダが行く最善の方法だと言えるかもしれません...しかし、あなたがパフォーマンスに優れているかを見るために(時間(counttrue ...))試してください – Matthew
あなたの推測は? – rnso
私はラムダが最も速いと信じます – Matthew