From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/22317 Path: news.gmane.org!not-for-mail From: Taco Hoekwater Newsgroups: gmane.comp.tex.context Subject: Re: Filling forms Date: Tue, 06 Sep 2005 16:47:20 +0200 Message-ID: <431DABF8.8070209@elvenkind.com> References: <431D92C0.3020706@gmail.com> <431D9712.5060107@logosrl.it> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1126018189 22443 80.91.229.2 (6 Sep 2005 14:49:49 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 6 Sep 2005 14:49:49 +0000 (UTC) Original-X-From: ntg-context-bounces@ntg.nl Tue Sep 06 16:49:48 2005 Return-path: Original-Received: from ronja.vet.uu.nl ([131.211.172.88] helo=ronja.ntg.nl) by ciao.gmane.org with esmtp (Exim 4.43) id 1ECejQ-0001KL-57 for gctc-ntg-context-518@m.gmane.org; Tue, 06 Sep 2005 16:47:28 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 9881D127F4; Tue, 6 Sep 2005 16:47:27 +0200 (CEST) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 20243-01-3; Tue, 6 Sep 2005 16:47:23 +0200 (CEST) Original-Received: from ronja.vet.uu.nl (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id C258D127EA; Tue, 6 Sep 2005 16:47:23 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 9DF2A127ED for ; Tue, 6 Sep 2005 16:47:22 +0200 (CEST) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 20204-01-4 for ; Tue, 6 Sep 2005 16:47:21 +0200 (CEST) Original-Received: from glenfiddich.elvenkind.com (elvenknd.xs4all.nl [213.84.171.68]) by ronja.ntg.nl (Postfix) with ESMTP id 6CB88127EA for ; Tue, 6 Sep 2005 16:47:21 +0200 (CEST) Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by glenfiddich.elvenkind.com (Postfix) with ESMTP id 1B41F181F9 for ; Tue, 6 Sep 2005 16:47:21 +0200 (CEST) Original-Received: from glenfiddich.elvenkind.com ([127.0.0.1]) by localhost (glenfiddich.elvenkind.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 05102-03 for ; Tue, 6 Sep 2005 16:47:20 +0200 (CEST) Original-Received: from [10.10.0.6] (glenlivet.elvenkind.com [10.10.0.6]) by glenfiddich.elvenkind.com (Postfix) with ESMTP id C53DB18195 for ; Tue, 6 Sep 2005 16:47:20 +0200 (CEST) User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) X-Accept-Language: en-us, en Original-To: mailing list for ConTeXt users In-Reply-To: <431D9712.5060107@logosrl.it> X-Virus-Scanned: by amavisd-new at elvenkind.net X-Virus-Scanned: amavisd-new at ntg.nl X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.5 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: ntg-context-bounces@ntg.nl Errors-To: ntg-context-bounces@ntg.nl X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on smtp.ntg.nl X-Virus-Scanned: amavisd-new at ntg.nl Xref: news.gmane.org gmane.comp.tex.context:22317 Archived-At: Hi Luigi, It is hard to benchmark stuff without the actual dataset, but I have some hints that may help you. (I hope my prose is not too confusing). luigi.scarso wrote: > Hi, I'm working on a project that require filling forms. > Every field has (x,y,width,height) dimension and > ui=(barcode,texEdit) type (textEdit has some attributes too) I would have used two separate macros then, one for barcodes and one for textEdit. More macros that each do less is generally faster than fewer macros that do more. If you have 200 fields, don't be scared to define 200 named macros for them > > \def\Field[#1]{% > \bgroup > \getparameters[!!][#1]%% collect key/val You could use \rawgetparameters in this kind of input. It is a lot faster and you have complete control over spaces in the input, so there is no need to use the slower \getparameters. > % > % > %%%% textEdit > \doifsamestring{\!!ui}{textEdit}{% text field \doifsamestring is quite slow. A faster solution: most arguments can only be one or two different things, right? Then you can predefine a macro for the possible cases, say \dotextEdit and \dobarcode, and replace most of the body of the \Field command with \getvalue{do\!!ui} I would suggest you try to do this pre-defining trick for all things you can possibly get away with. String comparisons in macro code are very expensive compared to the C lookup times for macro names. Another example: \doifsamestring{\!!para@hAlign}{left}{% \hbox to \!!w {\getvalue\s!dummy \vphantom{K} \getvalue\!!name \hss}% }% is a lot slower than: \def\parahAlignleft{% in the preamble \hbox to \!!w {\getvalue\s!dummy \vphantom{K} \getvalue\!!name \hss}% } followed by \getvalue{parahAlign\!!para@hAlign} % in actual code What is that \getvalue\s!dummy doing there, btw? I don't see what purpose it serves. You can also gain a considerable bit of speed by using an explicit \hrule with the correct size, instead of \vphantom{K}. Or just put the dimensions in a global \hbox beforehand: % in the preamble \newbox\Kbox \setbox\Kbox=\hbox{\vphantom{K}} \def\parahAlignleft{% \hbox to \!!w {\getvalue\s!dummy \copy\Kbox \getvalue\!!name \hss}% } Oh, and grouping is also slow. Why would you bother restoring stuff if you will overwrite the values before the next use ? There is no need for \bgroup ...\egroup around the pages if every page defines every field anyway. I'm quite confident that a near-optimal solution will look like this: ... lots and lots of macro defs, \starttext %% Some 200 \getvalue calls \getvalue{codicearticolo_len6}{957803} \getvalue{barcode_codice___matricola}{*9F9578030052201312*} \page Final trick: when in doubt, run TeX with \tracingall \tracingonline=0 in the preable, on an input file of just a few pages. The general rule of thumb is: the smaller log file, the faster the 'real' run will be. I hope this helps, Taco