J
Jeff
OptimizeIt accused one of my run methods of consuming 20% of cpu. However,
it's just a wait() followed by a switch statement. The method called by the
accused, addMeasurement(), only consumes 3%. So there's 17% of cpu that
is supposedly consumed by the accused run method.
Does wait cost significant cpu or is OptimizeIt accounting for waiting time
as cpu usage? BTW, I posted to the OptimizeIt newsgroup, but didn't get an
answer.
Thanks
Here's the method:
public void run() {
while( true ) {
synchronized( myQueue ) {
try {
myQueue.wait();
}
catch (InterruptedException e) { cat.warn("Exception: " + e+
" while waiting on my BarData"); }
while ( myQueue.size() > 0 ) {
reportCard = (ReportCard) myQueue.removeLast();
switch ( reportCard.eventIdentifier ) {
case id1 :
tdAlarm.addMeasurement( reportCard );
break;
case id2 :
faAlarm.addMeasurement( reportCard );
break;
case id3 :
fffAlarm.addMeasurement( reportCard );
break;
case id4 :
fcAlarm.addMeasurement( reportCard );
break;
}
} // while q > 0
} // sync
} // while true
} // close run
it's just a wait() followed by a switch statement. The method called by the
accused, addMeasurement(), only consumes 3%. So there's 17% of cpu that
is supposedly consumed by the accused run method.
Does wait cost significant cpu or is OptimizeIt accounting for waiting time
as cpu usage? BTW, I posted to the OptimizeIt newsgroup, but didn't get an
answer.
Thanks
Here's the method:
public void run() {
while( true ) {
synchronized( myQueue ) {
try {
myQueue.wait();
}
catch (InterruptedException e) { cat.warn("Exception: " + e+
" while waiting on my BarData"); }
while ( myQueue.size() > 0 ) {
reportCard = (ReportCard) myQueue.removeLast();
switch ( reportCard.eventIdentifier ) {
case id1 :
tdAlarm.addMeasurement( reportCard );
break;
case id2 :
faAlarm.addMeasurement( reportCard );
break;
case id3 :
fffAlarm.addMeasurement( reportCard );
break;
case id4 :
fcAlarm.addMeasurement( reportCard );
break;
}
} // while q > 0
} // sync
} // while true
} // close run