3714N/A/*
3714N/A * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
3714N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3714N/A *
3714N/A * This code is free software; you can redistribute it and/or modify it
3714N/A * under the terms of the GNU General Public License version 2 only, as
3714N/A * published by the Free Software Foundation.
3714N/A *
3714N/A * This code is distributed in the hope that it will be useful, but WITHOUT
3714N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3714N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3714N/A * version 2 for more details (a copy is included in the LICENSE file that
3714N/A * accompanied this code).
3714N/A *
3714N/A * You should have received a copy of the GNU General Public License version
3714N/A * 2 along with this work; if not, write to the Free Software Foundation,
3714N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
3714N/A *
3714N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
3714N/A * or visit www.oracle.com if you need additional information or have any
3714N/A * questions.
3714N/A */
3714N/A
3714N/A/**
3714N/A * @test
3714N/A * @bug 6328154 6962082
3714N/A * @summary ensure that ascii, and latin-1 text without combining marks, both layout faster
3714N/A * than latin-1 text with combining marks. The presumption is then that the canonical
3714N/A * GSUB table is being run only on the latter and not on either of the former.
3714N/A */
3714N/A
3714N/Aimport java.awt.Font;
3714N/Aimport java.awt.GraphicsEnvironment;
3714N/Aimport java.awt.font.FontRenderContext;
3714N/Aimport java.awt.font.TextLayout;
3714N/A
3714N/Aimport static java.awt.Font.*;
3714N/A
3714N/Apublic class CombiningPerf {
3714N/A private static Font font;
3714N/A private static FontRenderContext frc;
3714N/A
3714N/A public static void main(String[] args) throws Exception {
3714N/A System.err.println("start");
3714N/A
3714N/A GraphicsEnvironment.getLocalGraphicsEnvironment();
3714N/A
3714N/A font = new Font("Lucida Sans Regular", PLAIN, 12);
3714N/A frc = new FontRenderContext(null, false, false);
3714N/A
3714N/A String ascii = "the characters are critical noodles?";
3714N/A String french = "l'aper\u00e7u caract\u00e8re one \u00e9t\u00e9 cr\u00e9\u00e9s";
3714N/A String frenchX = "l'aper\u00e7u caracte\u0300re one e\u0301te\u0301 ere\u0301e\u0301s";
3714N/A
3714N/A // warmup
3714N/A for (int i = 0; i < 100; ++i) {
3714N/A TextLayout tl = new TextLayout(french, font, frc);
3714N/A tl = new TextLayout(ascii, font, frc);
3714N/A tl = new TextLayout(frenchX, font, frc);
3714N/A }
3714N/A /**/
3714N/A long atime = test(ascii);
3714N/A System.err.println("atime: " + (atime/1000000.0) + " length: " + ascii.length());
3714N/A
3714N/A long ftime = test(french);
3714N/A System.err.println("ftime: " + (ftime/1000000.0) + " length: " + french.length());
3714N/A
3714N/A long xtime = test(frenchX);
3714N/A System.err.println("xtime: " + (xtime/1000000.0) + " length: " + frenchX.length());
3714N/A
3714N/A long limit = xtime * 2 / 3;
3714N/A if (atime > limit || ftime > limit) {
3714N/A throw new Exception("took too long");
3714N/A }
3714N/A /**/
3714N/A }
3714N/A
3714N/A private static long test(String text) {
3714N/A long start = System.nanoTime();
3714N/A for (int i = 0; i < 2000; ++i) {
3714N/A TextLayout tl = new TextLayout(text, font, frc);
3714N/A }
3714N/A return System.nanoTime() - start;
3714N/A }
3714N/A}