views:

695

answers:

6

Is there any performance counter? Or i really get result like that:

Jagged Arrays: 2000 ms
Arrays : 3000 ms
ArrayList : 4000 ms


How can i code method to get performance result?

+6  A: 

The stopwatch class is useful for timing microbenchmarks:

http://msdn.microsoft.com/en-us/library/system.diagnostics.stopwatch.aspx

Brian
+2  A: 

Rico Mariani is your man. he makes the best performance staticstics for .net.

so, to start how to do it, read his blog.

How to test Array speed

results of these tests

basically, what you should mesure is the access of the items. not adding them.

cRichter
A: 

Performance of different storage structures will vary depending on the operations you require to carry out on said structure.

General tests might be
Sorting: Bubble, Merge
Searching: Sequential, Sequential (with unsorted data), Binary

Writing a function for testing these would involve filling up some arrays with an equal amount of random data and then performing the tests.

Producing time based metrics of performance is generally pretty simple with these types of algorithms.

Depending on language, you can time how long it takes to compute with the use of timers or simply storing/outputting the timestamps of each iteration point you choose.

jim
A: 

You can set some performance counter on application and then measure the performance..

Here is the good link. http://www.codeproject.com/KB/dotnet/perfcounter.aspx

jalpesh
+1  A: 

Honestly, if you need a profiler to tell you it's working better, you probably don't need to worry about it. So, just compile your code three different ways -- jagged arrays, array lists, and array classic. If any of them consistently runs [job X] noticeably faster, you've got it. If you can't feel the improvement firsthand, you're probably just wasting your most valuable resource: developer time.

ojrac
A: 

creat class jagged that contains 2 jagged array as follows 0 0123
01 012 012 01 0123 0 and two constructors.then creat class matrix that inherits jagged class,and contains two dimensional array and 2 method: 1-creat_matrix method :that creat the matrix from the two inherited jagged arrays as follows: 0 0 1 2 3 0 1 0 1 2 0 1 2 0 1 0 1 2 3 0 2-display method:disply the two jagged and the resulted matrix.

ramy yhya