How to compute the complexity

is there any software or debugger that can compute for me the time and space(memory) complexity?

for example if i have two Java codes which do the same function, and i want to check which takes memory less.

time is not important because by the theories of complexity i can check it.

any help in that?

[325 byte] By [Mina_Daouda] at [2007-11-27 10:27:28]
# 1

no solution for this?

Mina_Daouda at 2007-7-28 17:45:58 > top of Java-index,Java Essentials,Java Programming...
# 2

There are a series of profilers that you can use to determine memory and resource use in your program.

Other tools like PMD will review your code and provide suggestions for improvement and best practice.

maple_shafta at 2007-7-28 17:45:58 > top of Java-index,Java Essentials,Java Programming...
# 3

Thanks for helping, But what's the name of a software which compute the resources usage?

Mina_Daouda at 2007-7-28 17:45:58 > top of Java-index,Java Essentials,Java Programming...
# 4

a free profiler is JProfiler another is JmemProf. I think you will find JmemProf the easiest to learn.

An alternative to a profiler is to count the number of elements in your arrayList (or whatever type of collection you have) and multiply it by the type of storage element each cell in the array has (for example, each cell is an integer). Example: if an integer is 4 bytes and you have 1234 elements in the array, size is= 4*1234.

***************

Here is a way to measure how long your code takes to run:

Calendar calendar1= Calendar.getInstance();

//put your code you want to time here

Calendar calendar2= Calendar.getInstance();

long differenceInTIme=

calendar2.getTimeInMillis() - calendar2.getTimeInMillis();

George123a at 2007-7-28 17:45:58 > top of Java-index,Java Essentials,Java Programming...
# 5

Ya i got it. Thanks a lot for you help :-)

Mina_Daouda at 2007-7-28 17:45:58 > top of Java-index,Java Essentials,Java Programming...