From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10886 invoked from network); 21 May 1999 08:12:55 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 21 May 1999 08:12:55 -0000 Received: (qmail 6901 invoked by alias); 21 May 1999 08:12:42 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 6323 Received: (qmail 6894 invoked from network); 21 May 1999 08:12:41 -0000 From: "Andrej Borsenkow" To: "ZSH workers mailing list" Subject: Speed of ZSH Date: Fri, 21 May 1999 12:11:59 +0400 Message-ID: <001a01bea361$994a2140$21c9ca95@mow.siemens.ru> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 I recently needed to do a quick prototyping, and selected zsh just for the easy programming. The task was: I get a file with records of length 2040 characters and need to extract several (~100) fixed width fields and write them out separated by tabs. I had a list of fields in the form n1-n2, so I just vi'ed them :-) to get $line[n1,n2]. The problems I got were: 1. I found, that it is near to impossible to ``read'' line without breaking it on IFS. ``read -k'' did not work :-( After some play I found, that unsetting IFS helps - not very nice. How useful would it be to add a flag that says "read entire line in scalar variable without splitting"? 2. It is impossible to ``print'' arguments separated by user defined string (only NL or NUL). I had to make an array out of fields, and then print it with explicit join: fields=( $line[n1,n2] ...) print ${(j/\t/)fields} (Aside: how useful would it be to add flag to ``print'' to define separator?) After doing it I found, that ZSH needs several seconds for a file with 28 records! That is really too much for such a simple task. I suspect, the reason is constant reallocation of memory when first array is created (remember, it has about 100 elements) and then when it is joined. If anybody interested, I could recompile with profiling. I don't use zsh-mem mostly because I don't understand, what it actually is :-) /andrej