Article View: adobe.scripting.indesign
Article #21004Re: ID Win/VB Scripting Benchmarks
From: Greg Brunet
Date: Wed, 15 May 2002 18:38
Date: Wed, 15 May 2002 18:38
29 lines
6027 bytes
6027 bytes
Hey Ole:
I've done some scripting with other environments (especially Visio), and found that you could sometimes get dramatic improvements by handling the display properly - I'm glad to see that the minimize trick works. I've just placed the code at the bottom of this post - hope that's okay. I call the routine on a form with a button and a text box (txtResults) - that way I can easily copy the results. FWIW, I also always code with "Option Explicit" on. The code also has a test to get the "length/height" of the ad - even though it's not part of the text composition, it's something that I'll be needing to do in the actual code, so I've included it in my test. Of course the real project will involve reading the ads from a database, but for testing purposes, this let's me know what kind of overhead ID is going to add to the mix. Also, I start with ID already open and a new blank letter sized document open. I delete the text frame after each test, and manually minimize or restore the document window.
I initially did the testing with my display performance set to typical. I added code in the sample to switch it to optimized and ended up with the following results: ' timings: (optimized display) compiled, @ 850 MHz, 500x: ' displayed - Seconds: 21.160 - per ad: 0.042 ' minimized - Seconds: 12.801 - per ad: 0.026 As you can see, these are slightly higher than the values from the 'typical' run - but as happens with any benchmarking, there may be other things that are slightly different on my machine from when I ran the first set last night. I've tried to have most all other programs shut down in both cases - but there are sure to be things that I don't have control over that may impact performance.
I agree & understand that text-composition is going to be processor & time intensive. That's why I ran this benchmark before we got too far along into development. In an older version of our system, I handled the text composition on my own, including the justification and some rudimentary hyphenation. The hyphenation wasn't dictionary & rules based however, and I wouldn't have even begun to try & touch the Word & Letter spacing, & Glyph scaling. Hopefully I'm making the right strategic choice, but my intention is to accept the performance hit in order to provide the extra features (at 6000 ads, the old system can calculate the ad lengths in a fraction of a second, where I'm expecting about 140 seconds based on the numbers above).
One thing that would help me is to know what kind of machine I should target for running the app on. I assume something with good (fast) floating point numbers. I'll have to dig around to see if I should be looking at a Pentium, or maybe an AMD Athlon. If anyone has recommendations in this area, that would also really help.
Anyway - it's looking like integrating our system with ID is going to make an awesome product - my job right now is to check for any showstoppers as far as how I can control ID (haven't found any so far), and wring as much performance out it it as I can.
-- Greg
Sub CalcHeight()
Dim myInDesign As InDesign.Application Dim myDoc As InDesign.Document Dim myTF As InDesign.TextFrame Dim myPage As InDesign.Page Dim myIndex As Integer Dim i As Integer Dim dBaseline1 As Double Dim dHorizOffset1 As Double Dim dBaseline2 As Double Dim dHorizOffset2 As Double Dim dHeight As Double Dim t1 As Single, t2 As Single Dim nLoop As Integer Dim myDPP As InDesign.DisplayPerformancePreference
' Set myInDesign = New InDesign.Application '** should work but doesn't Set myInDesign = CreateObject("InDesign.Application.2.0") '** have to do it this way Set myDPP = myInDesign.DisplayPerformancePreferences myDPP.DefaultDisplaySettings = idDisplayOptimized myDPP.IgnoreLocalSettings = True ' Set myDoc = myInDesign.Documents.Add Set myDoc = myInDesign.Documents.Item(1)
Set myPage = myDoc.Pages.Item(1) Set myTF = myPage.TextFrames.Add ' - set width of our columns myTF.GeometricBounds = Array("0p", "0p", "63p", "1.92i") ' Set myTF = myPage.TextFrames.Item(1)
dBaseline1 = myTF.InsertionPoints.Item(1).Baseline dHorizOffset1 = myTF.InsertionPoints.Item(1).HorizontalOffset
' - needs to have some text before we can set justification! myTF.TextContents = "x" ' - set TF justification (just center/right) myTF.Paragraphs.Item(1).Justification = idRightJustified ' - once it's done, we can clear it! myTF.TextContents = ""
nLoop = 500 t1 = Timer For i = 1 To nLoop myTF.TextContents = "BICYCLE: Gary Fisher mt. bike, model Kaitai, 27 speeds, Shimano, Dior LX components, Rock shocks, front alum. frame, EC.$550 (304) 279-5002" myIndex = myTF.InsertionPoints.Count dBaseline2 = myTF.InsertionPoints.Item(myIndex).Baseline dHorizOffset2 = myTF.InsertionPoints.Item(myIndex).HorizontalOffset If (dBaseline1 <> dBaseline2) Or (dHorizOffset1 <> dHorizOffset2) Then dHeight = dBaseline2 Else dHeight = 0 End If Next i t2 = Timer txtResults = "Seconds: " & Format$(t2 - t1, "0.000") & " - per ad: " & Format$((t2 - t1) / nLoop, "0.000")
End Sub
Technical Details
Message-ID:
<ef88bb9.2@WebX.aaQKaf7vad4>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!peer.news.opaltelecom.net!newsfeed.wirehub.nl!news-hub.siol.net!fr.clara.net!heighliner.fr.clara.net!newsfeed01.sul.t-online.de!t-online.de!WebXReferences:
<ef88bb9.-1@WebX.aaQKaf7vad4>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f939a,99ecf9d043a22de5 X-Google-Attributes: gidf939a,public X-Google-ArrivalTime: 2002-05-15 12:08:41 PST From: "Greg Brunet" <gbrunet@sempersoft.com> Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!peer.news.opaltelecom.net!newsfeed.wirehub.nl!news-hub.siol.net!fr.clara.net!heighliner.fr.clara.net!newsfeed01.sul.t-online.de!t-online.de!WebX Newsgroups: adobe.scripting.indesign Subject: Re: ID Win/VB Scripting Benchmarks Message-ID: <ef88bb9.2@WebX.aaQKaf7vad4> Date: Wed, 15 May 2002 11:38:38 -0700 References: <ef88bb9.-1@WebX.aaQKaf7vad4> Lines: 122 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit