蛋疼,例項對比迴圈的寫法

2021-08-30 18:49:04 字數 834 閱讀 9618

看了[url] 閒的蛋疼,寫了個測試類看看什麼情況。廢話不說,上乾貨。以下是時間相關的效能表現。由於jprofiler的license過期,以後有時間貼上記憶體和cpu開銷。或者誰有空給**弄過去跑一下對比看看。

編譯和執行環境:ecipse/sun jdk1.6

輸出結果:

variableandindexinloop-->26962812

singlevariableindexinloop-->25436628

singlevariableindexoutloop-->25432976

novariableindexoutloop-->24568063

結論:【請看各位精彩回帖】。

package performance;

public class performance

static abstract class strategy

}protected int sum;

long measure()

abstract void howtodo();

}static class variableandindexinloop extends strategy }}

static class singlevariableindexinloop extends strategy }}

static class singlevariableindexoutloop extends strategy }}

static class novariableindexoutloop extends strategy }}

}

蛋疼的遞迴

幾個經典的遞迴場景 1.斐波那契 2.二叉樹的周遊 深度 前中後序 3.全排列問題 非簡單的全排列 允許字母重複 4.尋找滿足條件的n個數 第乙個的變種 跳台階 題目 乙個台階總共有n 級,如果一次可以跳1 級,也可以跳 2 級。求總共有多少總跳法,並分析演算法的時間複雜度。第二個要複習下非遞迴的寫...

令人蛋疼的ByteArray

最近做的乙個專案需要上傳比較多的到伺服器,伺服器限制大小是2m,在專案中,的大小都是有控制的,為100k 在互動中,返回給我 http status 413 上傳實體過大,超過伺服器大小。這讓我很糾結,我傳給伺服器的是二進位製流 bytearray 然後想當然的去計算,上傳的在10張以內,每張大小都...

dwr的蛋疼問題

最近在使用dwr,與之前相比 除了讓人非常蛋疼的問題,先描述如下 第乙個問題是伺服器向客戶端推送的時候,1 browser.withcurrentpage new runnable 13 使用該方法推送給當前的session使用,可是我之前測試總是在全部推送完畢後,才在頁面做接收,也就是看不到 一條...