Details
-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
7u65
-
x86_64
-
windows_7
Description
FULL PRODUCT VERSION :
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) Client VM (build 24.51-b03, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
Performance of FontMetrics calculation is very slow if in the text at least one letter is Hebrew
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the attached sample code.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Performs much slower with Hebrew text.
ACTUAL -
Performance should be same as with English text.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
public class TestHebrewPerformance
{
public static void main( String args[] ) {
String hebrew= "הָאָֽרֶץ׃ בְּרֵאשִׁ֖יאֱלֹהִ֑ת הַשָּׁמַ֖יִם וְאֵ֥ת הָאָֽ";
//String hebrew= "abcde()agjkljkjelwkהָ";
String english="abcde()agjklj;lkjelwk";
FontMetrics fm=createFontMetrics(new Font("dialog",Font.PLAIN,12));
int size=50000;
long start=System.currentTimeMillis();
for(int i=0;i<size;i++)
{
fm.stringWidth(hebrew);
}
System.out.println("Calculation time for hebrew: "+(System.currentTimeMillis()-start)+" ms");
start=System.currentTimeMillis();
for(int i=0;i<size;i++)
{
fm.stringWidth(english);
}
System.out.println("Calculation time for english: "+(System.currentTimeMillis()-start)+" ms");
}
private static FontMetrics createFontMetrics(Font font)
{
BufferedImage bi = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB_PRE);
Graphics g = bi.getGraphics();
FontMetrics fm = g.getFontMetrics(font);
g.dispose();
bi = null;
return fm;
}
}
---------- END SOURCE ----------
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) Client VM (build 24.51-b03, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
Performance of FontMetrics calculation is very slow if in the text at least one letter is Hebrew
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the attached sample code.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Performs much slower with Hebrew text.
ACTUAL -
Performance should be same as with English text.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
public class TestHebrewPerformance
{
public static void main( String args[] ) {
String hebrew= "הָאָֽרֶץ׃ בְּרֵאשִׁ֖יאֱלֹהִ֑ת הַשָּׁמַ֖יִם וְאֵ֥ת הָאָֽ";
//String hebrew= "abcde()agjkljkjelwkהָ";
String english="abcde()agjklj;lkjelwk";
FontMetrics fm=createFontMetrics(new Font("dialog",Font.PLAIN,12));
int size=50000;
long start=System.currentTimeMillis();
for(int i=0;i<size;i++)
{
fm.stringWidth(hebrew);
}
System.out.println("Calculation time for hebrew: "+(System.currentTimeMillis()-start)+" ms");
start=System.currentTimeMillis();
for(int i=0;i<size;i++)
{
fm.stringWidth(english);
}
System.out.println("Calculation time for english: "+(System.currentTimeMillis()-start)+" ms");
}
private static FontMetrics createFontMetrics(Font font)
{
BufferedImage bi = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB_PRE);
Graphics g = bi.getGraphics();
FontMetrics fm = g.getFontMetrics(font);
g.dispose();
bi = null;
return fm;
}
}
---------- END SOURCE ----------