Re: selectImage(title) is slow in Java 8

Posted by vischer on
URL: http://imagej.273.s1.nabble.com/selectImage-title-is-slow-in-Java-8-tp5018076p5018081.html

Hi Wayne and Gabriel,

> The latest ImageJ daily build (1.51k5) reduces the selectImage() timeout to 250 ms when ImageJ is running on OS X and Java 8. The timeout is the amount of time selectImage() waits for the image window to be activated. On OS X and Java 8, the window activated event sometimes does not occur after selectImage() calls toFront() on the image window.
>
> -wayne


thanks Wayne for the work-around. Now about every second call hits the 250 ms, so I wonder what will be the disadvantage in these cases?
The modified macro (below) makes tests in 4 loops, where loop 3 and 4 introduce BatchMode statements. This reduced the time to 0 msec.

Norbert


ImageJ 1.51k5; Java 1.8.0_101 [64-bit]; Mac OS X 10.10.3; 15MB of 3000MB (<1%)

//--- macro (with BatchMode statements) begin
run("Close All");
for(num=1; num <=6; num++){
        title = "Img_" + num;
        newImage(title, "8-bit ramp", 800, 600, 1);

}
print("\\Clear");
for(loop = 1; loop <= 4; loop++){
        print(loop);
        for(num=1; num <=6; num++){
                title = "Img_" + num;
                time = getTime;
                if(loop>2) setBatchMode(true);
                selectImage(title);
                if(loop>2) setBatchMode(false);
                print(title,  "time[ms]: ", getTime-time);
        }
}
selectWindow("Log");
//--- macro end


Output:
=======
1
Img_1 time[ms]:  60
Img_2 time[ms]:  31
Img_3 time[ms]:  254
Img_4 time[ms]:  58
Img_5 time[ms]:  263
Img_6 time[ms]:  23
2
Img_1 time[ms]:  57
Img_2 time[ms]:  32
Img_3 time[ms]:  253
Img_4 time[ms]:  36
Img_5 time[ms]:  261
Img_6 time[ms]:  23
3
Img_1 time[ms]:  0
Img_2 time[ms]:  0
Img_3 time[ms]:  0
Img_4 time[ms]:  0
Img_5 time[ms]:  0
Img_6 time[ms]:  0
4
Img_1 time[ms]:  0
Img_2 time[ms]:  0
Img_3 time[ms]:  0
Img_4 time[ms]:  0
Img_5 time[ms]:  0
Img_6 time[ms]:  0

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html