M
Marcin Rodzik
Hello,
I'm trying to optimize my program. The basic idea of it is that it
consists of a few separate threads each of which performs another
operation on an object. The objects which are undergone these
operations are passed over from one thread to another. Operations on
each object are performed sequentially, however, all the threads work
concurrently. This is because some operations need additional
resources (one of threads simply sends data over the network, another
receives some data).
Now I'd like to know which thread is the most computation-intensive,
i.e. which takes the most of the CPU time. Is there any simple way to
check this? What I came up with is re-writing the program so that one
thread is used and simply check the time each operation takes with
double invocation of Calendar.getInstance().getTimeInMillis().
However, it's not so easy. Moreover, I'd like to check the time in a
"real environment", it means that I want to include the time the
threads are blocked waiting for I/O and so on.
Another question which is not clear to me: What really happens when a
thread waits for incoming data e.g. from a socket? To what extent can
the other threads use the CPU?
MR
I'm trying to optimize my program. The basic idea of it is that it
consists of a few separate threads each of which performs another
operation on an object. The objects which are undergone these
operations are passed over from one thread to another. Operations on
each object are performed sequentially, however, all the threads work
concurrently. This is because some operations need additional
resources (one of threads simply sends data over the network, another
receives some data).
Now I'd like to know which thread is the most computation-intensive,
i.e. which takes the most of the CPU time. Is there any simple way to
check this? What I came up with is re-writing the program so that one
thread is used and simply check the time each operation takes with
double invocation of Calendar.getInstance().getTimeInMillis().
However, it's not so easy. Moreover, I'd like to check the time in a
"real environment", it means that I want to include the time the
threads are blocked waiting for I/O and so on.
Another question which is not clear to me: What really happens when a
thread waits for incoming data e.g. from a socket? To what extent can
the other threads use the CPU?
MR