" +\n "Loop 2: ");\n Response.Write(s2.ElapsedMilliseconds);\n }\n}','The benchmarking code',' has some problems. The second block sometimes takes less time to execute due to unknown causes. Repeat and swap two loops if you are doubtful. The first program shown converts the results to nanoseconds.','For','for','Tip:','It is usually best to report results in nanoseconds or microseconds with the number of iterations used to divide the result.','Convert Nanoseconds','convert-nanoseconds','Stopwatch','stopwatch','Discussion.',' Is benchmarking important? Yes\u2014however, it is often not important in a practical sense for your current project. It encourages you to examine your code and find out what it is really doing.','Example optimization.',' The Dictionary collection in the base class library is a huge optimization and reduces lookup time to a constant O(1). But developers sometimes write code that results in twice as many lookups.','TryGetValue','trygetvalue','Dictionary','dictionary','How to dig deeper.',' The JIT optimizer in .NET makes code really fast, but it can\'t fix everything. By benchmarking, I am able to tell what code is optimized. I gain insight into JITting.','Note:','With IL Disassembler, we can see the internals of our C# code. But another way to tell that code is doing less is to time it.','IL Disassembler','il-disassembler','And:','As computer scientists, we need to understand every part of how computer languages work.','Locality of reference',' is important to benchmark. Things that are near are faster to access. Astronomers will tell you the speed of light. Fundamental to science is locality of reference, and this carries over into the C# language.','Locality of Reference','locality-of-reference','Summary.',' We looked at example code for benchmarking the C# language. Benchmarking encourages careful thinking about your code. It saves nanoseconds from your software. It also improves the depth of your understanding.','And:','With benchmarking we able to grasp pipelining, file system caches, and locality of reference.','v','