看板 C_Sharp 關於我們 聯絡資訊
Performance Tips and Tricks in .NET Applications 文章Title 不知道為什麼 Jagged Arrays 會比 Rectangular arrays 好? Use Jagged Arrays—Version 1 The v1 JIT optimizes jagged arrays (simply 'arrays-of-arrays') more efficiently than rectangular arrays, and the difference is quite noticeable. Here is a table demonstrating the performance gain resulting from using jagged arrays in place of rectangular ones in both C# and Visual Basic (higher numbers are better): C# Visual Basic 7 Assignment (jagged) Assignment (rectangular) 14.16 8.37 12.24 8.62 Neural Net (jagged) Neural net (rectangular) 4.48 3.00 4.58 3.13 Numeric Sort (jagged) Numeric Sort (rectangular) 4.88 2.05 5.07 2.06 The assignment benchmark is a simple assignment algorithm, adapted from the step-by-step guide found in Quantitative Decision Making for Business (Gordon, Pressman, and Cohn; Prentice-Hall; out of print). The neural net test runs a series of patterns over a small neural network, and the numeric sort is self-explanatory. Taken together, these benchmarks represent a good indication of real-world performance. As you can see, using jagged arrays can result in fairly dramatic performance increases. The optimizations made to jagged arrays will be added to future versions of the JIT, but for v1 you can save yourself a lot of time by using jagged arrays. -- ----------------------------------------------------------------------------- 功課重,Project多的好幫手--專案王 http://steven.twbbs.org/ProjectKing 增加右鍵的威力RightMenuKing--右鍵王 http://steven.twbbs.org/RightMenuKing/ 備份重要檔案的好幫BackupKing--備份王 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.113.216.156
glenn7012:可能用jagged方式宣告的array比較有彈性 11/23 01:21
virdust2003:一般彈性跟效率都是反比的 11/25 00:50