Since the release of vs2010 for nearly half a year, although I want to learn new things all day, I found myself very lazy when I was about to update myself. It didn't take long for 2008, but I had to be 2010. After a few days, the IDE looks like 05 and 08. With some small features added, you can try it later. First, you feel that the startup speed is much slower. The main change lies in. Net 4.0. In fact, it refers to the revision and supplement, and the language features have almost no new features. C # has a dynamic and VB supports later binding 10 years ago. I had to pay attention to the Framework. The new parallel support should be the biggest change.
I have also visited the vs2010 press conference. Parallel support is a major selling point. At that time, I remember that one mm on the platform added asparallel () to a LINQ query statement, and the performance was magically doubled. It is indeed very easy to improve program performance, is the most interesting. When reading electronic journals, I saw an article by Leng and Wu Qin, which inspired me by these cainiao. I used to fall far behind college students.
Let's get started and start with parallel. First grab a pad back:
Staticvoid set (INT length)
{
VaR array = newint [length, length, length];
For (INT I = 0; I <length; I ++)
For (Int J = 0; j <length; j ++)
For (int K = 0; k <length; k ++)
Array [I, j, k] = system. Threading. thread. currentthread. managedthreadid;
}
Then let us know:
Staticvoid parallelset (INT length)
{
VaR array = newint [length, length, length];
Parallel. For (0, length, I =>
{
For (Int J = 0; j <length; j ++)
For (int K = 0; k <length; k ++)
Array [I, j, k] = system. Threading. thread. currentthread. managedthreadid;
});
}
PK:
Codetimer. Time ("single thread", 100, () => set (100 ));
Codetimer. Time ("multiple thread", 100, () => parallelset (100 ));
The result is 1136 Ms: 729 MS, which is really good. However, the msdn example may have been harmonized, so it will always change the test process. We found another one.