HP3000-L Archives

June 1999, Week 3

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Jason Quigley <[log in to unmask]>
Reply To:
Jason Quigley <[log in to unmask]>
Date:
Thu, 17 Jun 1999 14:18:00 +0200
Content-Type:
text/plain
Parts/Attachments:
text/plain (181 lines)
Hi Tad!
   Good to see you've got a sense of humour! ;-)

Cheers,
Jason.

[log in to unmask] wrote:
>
> Jason wrote :
>
> >> Whoaaa Tad!
> >>  Time to start the Obfuscated CI Contest!
>
> Hi Jason,
>
> I didnt really intend to start any contest, and perhaps I should have
> elaborated the point of my post, which was purely educational
> rather than obfuscational.
> Since this type of thread often ends up being educational to the
> less experienced members of the list, I thought I should contribute.
>
> While the logic of your routine is Ok, the efficiency in terms of CPU
> is rather low, conservatively I'd say about 20:1 compared with the
> version I offered and a lot more if the two input files were variable
> length type.
>
> This of course is not important for a one-off, or for a low volume job
> such as this, and maybe of no importance most of the time,
> but these bits of code have a habit of being 'cloned' and
> adapted for slightly different tasks, and then find their way into parts
> of jobs on production systems, becoming part of 'slow' jobs etc,
> and have their own way of eventually generating havoc with
> system performance.
>
> And even worse, a 'newbie' to the HP3000 may adopt the technique,
> and end up with a bad impression of the performance capability of
> our favourite machine and operating system.
>
> A quick analysis shows that EACH iteration of the loop inflicts
> 7 file opens, 7 closes, 4 reads, and 3 writes.
> (If the input files were variable length, then the number of reads performed
> by the print commands  would be  about n(n+1)  where n is the number of
> records in file1 , and this adds up to over 60000 reads when the number
> of records is 25. This is because print must sequentially read from record 1
> in order to locate a given record number as passed by the start= parameter)
>
> For example the first print statement, will open file1, open $newpass,
> locate record on file1, write to $newpass, close file1, and close $newpass.
> By comparison, the CNV125CF version will open file1 & 2  & 3 once only,
> close once only, and only issue 1 read and 1 write per input record.
>
> I think the CI is an extremely powerful and useful tool considering the
> small number of functions that it offers, and the relatively low learning-curve
> it requires. As with any tool like this, there are good ways of using it and
> even better ways, and it doesnt cost a lot of effort to adopt better ways
> where possible.
>
> Cheers,
>
> Tad.
>
> btw,  you should be aware of a common pitfall when using print on a task like
> this.
> When you print a record to $newpass, you are creating a variable length  record
> whose length may be truncated by the number of trailing blanks. So when you
> input from $oldpass, the receiving string variables (rec1 & rec2) may not have
> the length you expect, and their concatenation wont be what you want either.
>
> >purge newfile
> >purge newfile,temp
> >file newfile;rec=-125,,f,ascii;disc=250
> >setvar i, 1
> >while i<=250
> >  print file1;start=!i;end=!i >$newpass
> >   input rec1 <$oldpass
> >   print file2;start=!i;end=!i >$newpass
> >   input rec2 <$oldpass
> >   echo ![rec1]![rec2] >>*newfile
> >   setvar i, i+1
> >endwhile
> >save *newfile
>
> > Another CI version ,
> > (slightly quicker runtime, though limited by memory
> > available for CI variables).
> >
> > file FILEC;rec=-125,10,f,ascii
> > xeq CNV125CF FILEB < FILEA > *FILEC
> >
> > Command file CNV125CF :-
> >
> > parm fileb=FILEB
> > print !hpfile;start=-4 > tempcf
> > xeq tempcf.!hpgroup < !fileb
> > setvar n finfo(hpstdin,"eof")
> > while setvar(n,n-1)>=0
> >    echo ![input()+rec!n]
> > endwhile
> > return
> > setvar n finfo(hpstdin,"eof")
> > while setvar(n,n-1)>=0
> >    setvar rec!n  input()
> > endwhile
>
> [log in to unmask] on 16/06/99 12:24:19
>
> Please respond to [log in to unmask]
>
> To:   [log in to unmask]
> cc:    (bcc: Tad BOCHAN/Securities_Services/FR/PARIBAS)
> Subject:  Re: File manipulation
>
> Cheers,
> Jason.
>
> P.S. I like the way all those little bits of Korn/C Shell are gradually
> creeping into the CI! Hopefully we'll get some nice piping soon.
>
> [log in to unmask] wrote:
> >
> <snip>
> >
> > Another CI version ,
> > (slightly quicker runtime, though limited by memory
> > available for CI variables).
> >
> > file FILEC;rec=-125,10,f,ascii
> > xeq CNV125CF FILEB < FILEA > *FILEC
> >
> > Command file CNV125CF :-
> >
> > parm fileb=FILEB
> > print !hpfile;start=-4 > tempcf
> > xeq tempcf.!hpgroup < !fileb
> > setvar n finfo(hpstdin,"eof")
> > while setvar(n,n-1)>=0
> >    echo ![input()+rec!n]
> > endwhile
> > return
> > setvar n finfo(hpstdin,"eof")
> > while setvar(n,n-1)>=0
> >    setvar rec!n  input()
> > endwhile
> >
> <snip>
> >
> --
> ----------------------------------------------------
> Please note: I will be leaving HP on 25/06/1999
>
> As a result, all work requests should be directed to
> the Help Desk and not directly to my email address.
>
> Personal email can be sent to me at [log in to unmask]
> ----------------------------------------------------
>
> -----------------------------------------------------------------------------
> This message is confidential; its contents do not constitute a
> commitment by Paribas except where provided for in a written agreement
> between you and Paribas. Any unauthorised disclosure, use or
> dissemination, either whole or partial, is prohibited. If you are not
> the intended recipient of the message, please notify the sender
> immediately.
>
> Ce message est confidentiel ; son contenu ne reprisente en aucun cas un
> engagement de la part de Paribas sous riserve de tout accord conclu par
> icrit entre vous et Paribas. Toute publication, utilisation ou
> diffusion, mjme partielle, doit jtre autorisie prialablement. Si vous
> n'jtes pas destinataire de ce message, merci d'en avertir immidiatement
> l'expiditeur.

--
----------------------------------------------------
Please note: I will be leaving HP on 25/06/1999

As a result, all work requests should be directed to
the Help Desk and not directly to my email address.

Personal email can be sent to me at [log in to unmask]
----------------------------------------------------

ATOM RSS1 RSS2