質問

どのように私の最適化には、次のコード、2分取得ループを通じて800+の記録からはプールの100K記録、6分野毎の記録を追加し約20秒追加のフィールド):

<cfset dllPath="C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.DirectoryServices.dll" />
<cfset LDAPPath="LDAP://" & arguments.searchPath />
<cfset theLookUp=CreateObject(".NET","System.DirectoryServices.DirectoryEntry", dllPath).init(LDAPPath) />
<cfset theSearch=CreateObject(".NET","System.DirectoryServices.DirectorySearcher", dllPath).init(theLookUp) />
<cfset theSearch.Set_Filter(arguments.theFilter) />
<cfset theObject = theSearch.FindAll() />

<cfloop index="row" from="#startRow#" to="#endRow#">
   <cfset QueryAddRow(theQuery) />
   <cfloop list="#columnList#" index="col">
     <cfloop from="0" to="#theObject.Get_Item(row).Get_Properties().Get_Item(col).Get_Count()-1#" index="item">
       <cftry>
         <cfset theQuery[col][theQuery.recordCount]=ListAppend(theQuery[col][theQuery.recordCount],theObject.Get_Item(row).Get_Properties().Get_Item(col).Get_Item(item),"|") />
         <cfcatch type="any">
         </cfcatch>
        </cftry>
      </cfloop>
    </cfloop>
  </cfloop>
役に立ちましたか?

解決

大きさはどのくらいのリスト項目の内側のループ?

切り替える配列 高速になりがあればかなり多くの項目です。

して実施することx0nの提案...

<cfset dllPath="C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.DirectoryServices.dll" />
<cfset LDAPPath="LDAP://" & arguments.searchPath />
<cfset theLookUp=CreateObject(".NET","System.DirectoryServices.DirectoryEntry", dllPath).init(LDAPPath) />
<cfset theSearch=CreateObject(".NET","System.DirectoryServices.DirectorySearcher", dllPath).init(theLookUp) />
<cfset theSearch.Set_Filter(arguments.theFilter) />
<cfset theObject = theSearch.FindAll() />

<cfloop index="row" from="#startRow#" to="#endRow#">

    <cfset Props = theObject.get_item(row).get_properties() />

    <cfset QueryAddRow(theQuery) />

    <cfloop list="#columnList#" index="col">

        <cfset CurrentCol = Props.getItem(col) />

        <cfset ItemArray = ArrayNew(1)/>
        <cfloop from="0" to="#CurrentCol.getcount() - 1#" index="item">
            <cftry>
                <cfset ArrayAppend( ItemArray , CurrentCol.Get_Item(item) )/>
                <cfcatch type="any">
                </cfcatch>
            </cftry>
        </cfloop>
        <cfset theQuery[col][theQuery.recordCount] = ArrayToList( ItemArray , '|' )/>

    </cfloop>

</cfloop>

他のヒント

いて触ってCFが、日本語訳を見てもわかりませんのヒントに擬似コードです。一例を挙げると、この表現は極めてinefficent:

#theObject.Get_Item(行)。Get_Properties().Get_Item(col).Get_Count()-1#

けて行動を起こしてみてください一部例えば、Get_Item(行)-コード原因はCFを取得は行とその特性毎に繰り返し処理の#columnList#ループ;いや、やっているとの回数の繰りcolumnlist(ループの内cfset).考えてみればこのみのニーズを取得するrowの各繰り返し処理の外側のループから#sfstart#の#cfend).そこで擬似コードをい:

各列の間の開始と終了

cfset小道具=#theobject.get_item(行)。get_properties()#

各列には#columnlist#

cfset currentcol=#props.getitem(col)#

cfset count=#currentcol.getcount()-1#

foreach項目から0#カウント#

cfset#currentcol.getItem(項)#など---。

しょう?毎回入力するループのキャッシュオブジェクトの再利用はその範囲又は子供のスコープ)に変更します。これだけみのカラムオブジェクトに数回繰り返すカラムのループを実行します。すべての変数定義の外側のスコープの内側のスコープは、ご覧の通りかねます。んその魅力的にカット&ペーストから前線でいいたします。で痛みだします。

武器agiは、dexで下がらないboxerぐ,

Oisin

また、cftryブロックは各ループが鈍化すか。ない限り、期待を個別に行に失敗す(必要があるから引き続きこの点を提供しているシングルをtry/catchブロック全体のプロセス。Try/catchでも動作します。

いていると考えていたように多くの評価の内側ループでの使用変数保持カウント、ポインタの列オブジェクトの長さをかえるパイプstring delimまだコミットの準備にクエリオブジェクトです。ばねのリファクタリングを正しくべき知向上ご利用の場合は以下のコード:

<cfloop index="row" from="#startRow#" to="#endRow#">
<cfset QueryAddRow(theQuery) />
<cfloop list="#columnList#" index="col">
    <cfset PipedVals = "">
    <cfset theItem = theObject.Get_Item(row).Get_Properties().Get_Item(col)>
    <cfset ColCount = theItem.Get_Count()-1>
    <cfloop from="0" to="#ColCount#" index="item">
        <cftry>
        <cfset PipedVals = ListAppend(PipedVals,theItem.Get_Item(item),"|")>
        <cfcatch type="any"></cfcatch>
        </cftry>
    </cfloop>
    <cfset QuerySetCell(theQuery,col) = PipedVals>
</cfloop>

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top