[討論] Use Jagged Arrays
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
推
11/23 01:21, , 1F
11/23 01:21, 1F
推
11/25 00:50, , 2F
11/25 00:50, 2F
討論串 (同標題文章)
以下文章回應了本文:
完整討論串 (本文為第 1 之 2 篇):
C_Sharp 近期熱門文章
PTT數位生活區 即時熱門文章