サイクルまたは反復ステートメントのコストを知る方法があることは知っていますが、2 つのことを知りたいです。
1位。 これら 2 つのリストのうち、費用対効果が高いのはどれですか? (または、より良いアプローチがあれば、私はすべて耳を傾けています):
更新:質問は次のとおりです: 2 つのうちどれがメモリ/GC を適切に使用しますか? と の「値」はreqObj
、resObj
次のループでは必要ないことに注意してください。
for (TransactionLog transactionLog : transactionLogList) {
RequestObj reqObj = new RequestObj();
ResponseObj resObj;
try {
//do things with these 2 babes and the transactionLog
} catch (WhateverException ex) {
log.error("Error in XYZ while doing whatever", ex);
//execute code without throwing anything up
} finally {
reqObj = null;
resObj = null;
}
}
また
RequestObj reqObj = new RequestObj();
ResponseObj resObj;
for (TransactionLog transactionLog : transactionLogList) {
try {
//do things with these 2 babes and the transactionLog
} catch (WhateverException ex) {
log.error("Error in XYZ while doing whatever", ex);
//execute code without throwing anything up
} finally {
//do something
}
}
そして2番目。 この「アルゴリズムのベストプラクティス」と、相互関係のステートメントコストを計算するための関数 O(letter) を学ぶのに適した場所/本/サイトをどこで見つけることができますか?
PD: 私の英語で申し訳ありません... 彼はあまり格好良くありません. xD