-1

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?

Ronald Wildenberg
  • 31,634
  • 14
  • 90
  • 133
Penguen
  • 16,836
  • 42
  • 130
  • 205

7 Answers7

6

The stopwatch class is useful for timing microbenchmarks:

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

Brian
  • 117,631
  • 17
  • 236
  • 300
2

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
  • 1,411
  • 7
  • 7
1

You can have a look at this question, it has some code, results and discussion

Community
  • 1
  • 1
H H
  • 263,252
  • 30
  • 330
  • 514
1

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
  • 13,231
  • 6
  • 37
  • 39
0

create a class that contains 2 jagged array as follows

0    0123     
01   012  
012  01  
0123 0  

and two constructors. Then create a class that inherits jagged class, that contains a two dimensional array and 2 methods:

create_matrix method that creates 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

display method that displays the two jagged arrays and the resulted matrix.

0

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.

lsl
  • 4,371
  • 3
  • 39
  • 54
0

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 Vadgama
  • 13,653
  • 19
  • 72
  • 94