From dev-return-58652-archive-asf-public=cust-asf.ponee.io@pdfbox.apache.org Thu Oct 4 07:52:39 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 8D005180658 for ; Thu, 4 Oct 2018 07:52:38 +0200 (CEST) Received: (qmail 16418 invoked by uid 500); 4 Oct 2018 05:52:37 -0000 Mailing-List: contact dev-help@pdfbox.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@pdfbox.apache.org Delivered-To: mailing list dev@pdfbox.apache.org Received: (qmail 16406 invoked by uid 99); 4 Oct 2018 05:52:36 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 04 Oct 2018 05:52:36 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 7796B182287 for ; Thu, 4 Oct 2018 05:52:36 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.889 X-Spam-Level: * X-Spam-Status: No, score=1.889 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, T_DKIMWL_WL_MED=-0.01] autolearn=disabled Authentication-Results: spamd3-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id ixkM2DeSgHzP for ; Thu, 4 Oct 2018 05:52:34 +0000 (UTC) Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id BD9185F3E2 for ; Thu, 4 Oct 2018 05:52:33 +0000 (UTC) Received: by mail-wr1-f51.google.com with SMTP id n1-v6so8454678wrt.10 for ; Wed, 03 Oct 2018 22:52:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=iZE90aUWNcGn5mP5PcIfDwi40aw1pD7V4kpWrZN45bU=; b=iBFkRbsjjEEgNxKdrrCK/N1ncw7ueMmUMvjDhcZ7Am5+ObvTSyWw10VNBSgFVsobmY ARD/KRVV3BKFmCNY3vu9PEywUqGTbhsT5G+7o6volOwVH+o2uLEyE6r7r7QwQ4QtHcSb vhDeQ/6HuLCzuiXENVpqp2DQF12RN1QS63aaUD8+wH954gTGKxsatO2SObWx+l6OjbNQ /VkTiinsVdgMwW5F6HxgE8Mj76/2eZj1+jaHeDgA5r9t1YNdCoJMIqv6lRls1u7N76Ss NyVLs4M0misd9AwB4KYKWKBCXd9RTNczmjRI1GQIBo/yykQr30a20UmjZIimk1KEHpzn coig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=iZE90aUWNcGn5mP5PcIfDwi40aw1pD7V4kpWrZN45bU=; b=LevP4sA6LKzJqnIjeTTMDej0tGAdCuDxrCJiPjLyPsRohIdew4ZQNbgxdLGBaLfX3K rpTPSBqbk2ec0CpLpRKxUqDBKYXcLitrgc4wtmBiDb4/rKpU7EhwAQfq6VlN37cMPlZa jIcHWDje800d2kkN8ohoheMj6SoD90XnBWpvVfyL9L1siBLaY750InirHPFdfZHNU8ga tuQSJ2BC1h6ejDwFGjOKWSSeKIfHsCU9gNW6Cg/c4eHdPucJnk8ffoIJEpqxtVGvdnsL LDJIKv9Rtc4Eb3pD/g0ILN9yEA8Yre1G+CUi2Z6qhq+lkTrzqjvPmLGxGjMQKWq54qIY B8lw== X-Gm-Message-State: ABuFfogz5Ka1wwLqfwluaC7o1d+M2h+kO2AA/mDoMe1fty1pXwAmBbrb CcXqhAsMMIliEg1qHPBovm5Cug1TSu1FYW8ovepYpnq0 X-Google-Smtp-Source: ACcGV61DKAgrxBH+c1MJb3+NikWogDdAKkorNQCPblPP3exsDj3LecFAWMYnm7in/Znaipi8UJcbGhrj3DEL3fzHGFY= X-Received: by 2002:adf:bbc3:: with SMTP id z3-v6mr3414582wrg.183.1538632342245; Wed, 03 Oct 2018 22:52:22 -0700 (PDT) MIME-Version: 1.0 References: <495b24ca-dc16-f493-ae1f-2bf5058ee0d1@t-online.de> <72906fbd-7bf2-e417-b90b-4b814769d700@t-online.de> <0ad6522b-fb58-9aa8-a038-047b9aa55a9b@lehmi.de> In-Reply-To: <0ad6522b-fb58-9aa8-a038-047b9aa55a9b@lehmi.de> From: Daniel Persson Date: Thu, 4 Oct 2018 07:56:36 +0200 Message-ID: Subject: Re: Rendering images from PDF files slower in OpenJDK To: dev@pdfbox.apache.org Content-Type: multipart/alternative; boundary="0000000000003315e4057760c287" --0000000000003315e4057760c287 Content-Type: text/plain; charset="UTF-8" Hi Tilman and Andreas As we try different things I thought it good for collaboration to create a repository with the code so all can contribute. https://github.com/kalaspuffar/ColorConvTest I've run the 3 different tests on my Machine (Thinkpad P51s) with custom Gentoo installed, if important to the conversation. I tried to invite you all as collaborators to this repository if you think this is a bad Idea let me know. Best regards Daniel On Wed, Oct 3, 2018 at 10:31 PM Andreas Lehmkuehler wrote: > Am 03.10.2018 um 21:14 schrieb Daniel Persson: > > Hi Tilman > > > > Thank you for looking into this for me, I've run your code with different > > java versions and I can see the exact opposite time metrics. > > > > In my initial test Java 8 was fastest, Java 9 was slowest and 10-11 was > > somewhere in the middle. > > > > Maybe different color profiles are good at different images? > > Do you have any more suggestions? > Just a guess, but maybe you are comparing apples and oranges? It looks > like > Daniel is using Linux and AFAIK Tilman is using Windows. That could be the > reason for the different results. > > Andreas > > > I'll report these findings to Oracle tomorrow. > > > > Best regards > > Daniel > > > > $ java -jar target/ColorConvTest-1.0-SNAPSHOT-jar-with-dependencies.jar > > Raster: ByteInterleavedRaster: width = 2577 height = 1540 > #numDataElements > > 4 dataOff[0] = 0 > > 60178 > > > > $ /opt/openjdk/jdk-9.0.4/bin/java -jar > > target/ColorConvTest-1.0-SNAPSHOT-jar-with-dependencies.jar > > Raster: ByteInterleavedRaster: width = 2577 height = 1540 > #numDataElements > > 4 dataOff[0] = 0 > > 33327 > > > > $ /opt/openjdk/jdk-10.0.2/bin/java -jar > > target/ColorConvTest-1.0-SNAPSHOT-jar-with-dependencies.jar > > Raster: ByteInterleavedRaster: width = 2577 height = 1540 > #numDataElements > > 4 dataOff[0] = 0 > > 56596 > > > > $ /opt/openjdk/jdk-11/bin/java -jar > > target/ColorConvTest-1.0-SNAPSHOT-jar-with-dependencies.jar > > Raster: ByteInterleavedRaster: width = 2577 height = 1540 > #numDataElements > > 4 dataOff[0] = 0 > > 56988 > > > > > > On Wed, Oct 3, 2018 at 8:31 PM Tilman Hausherr > > wrote: > > > >> Am 03.10.2018 um 20:08 schrieb Tilman Hausherr: > >>> > >>> I could expand that one later so that it uses the raster of the actual > >>> JPEG image from your PDF. > >> > >> > >> Your JPEG file is here: > >> > >> > >> > https://drive.google.com/file/d/1HvXMet6Wygzmko9ZmY9_zlvhv72v_QHf/view?usp=sharing > >> > >> The modified code - please test on different openjdks. It took 137935 on > >> oracle jdk8. (you may want to change the "50") > >> > >> > >> > >> import java.awt.*; > >> import java.awt.color.*; > >> import java.awt.image.*; > >> import java.io.FileInputStream; > >> import javax.imageio.ImageIO; > >> import javax.imageio.ImageReadParam; > >> import javax.imageio.ImageReader; > >> import javax.imageio.stream.ImageInputStream; > >> import javax.imageio.stream.MemoryCacheImageInputStream; > >> > >> public class CConv > >> { > >> > >> static BufferedImage toRGBImageAWT(WritableRaster raster, > >> ColorSpace colorSpace) > >> { > >> > >> ColorModel colorModel = new ComponentColorModel(colorSpace, > >> false, false, Transparency.OPAQUE, > >> raster.getDataBuffer().getDataType()); > >> > >> BufferedImage src = new BufferedImage(colorModel, raster, > >> false, null); > >> BufferedImage dest = new BufferedImage(raster.getWidth(), > >> raster.getHeight(), > >> BufferedImage.TYPE_INT_RGB); > >> ColorConvertOp op = new ColorConvertOp(null); > >> //System.out.println("src="+src); > >> //System.out.println("dst="+dest); > >> op.filter(src, dest); > >> return dest; > >> } > >> > >> public static void main(String args[]) throws Exception > >> { > >> ImageReader reader = > >> ImageIO.getImageReadersByFormatName("JPEG").next(); > >> WritableRaster raster; > >> FileInputStream fis = new FileInputStream("cmyk.jpg"); > >> try (ImageInputStream iis = new > MemoryCacheImageInputStream(fis)) > >> { > >> reader.setInput(iis); > >> ImageReadParam irp = reader.getDefaultReadParam(); > >> raster = (WritableRaster) reader.readRaster(0, irp); > >> } > >> System.out.println("Raster: " + raster); > >> > >> ICC_Profile profile = > >> ICC_Profile.getInstance("ISOcoated_v2_300_bas.icc"); > >> ICC_ColorSpace colorSpace = new ICC_ColorSpace(profile); > >> long t0 = System.currentTimeMillis(); > >> for (int i = 0; i < 50; i++) > >> { > >> toRGBImageAWT(raster, colorSpace); > >> } > >> long t1 = System.currentTimeMillis(); > >> System.out.println((t1 - t0)); > >> } > >> } > >> > >> > >> --------------------------------------------------------------------- > >> To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org > >> For additional commands, e-mail: dev-help@pdfbox.apache.org > >> > >> > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org > For additional commands, e-mail: dev-help@pdfbox.apache.org > > --0000000000003315e4057760c287--