Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Speed-up/reduce CPU use of code

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler
View previous topic :: :: View next topic  
Author Message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1060
Location: Oostende, Belgium

PostPosted: Tue Sep 26, 2017 12:05 am    Post subject: Speed-up/reduce CPU use of code
Reply with quote

One of the programs I'm responsible for requires some new functionality, Top-nn tables, at least one summary set of three (Top-50) of distance, time, and velocity, but potentially rather a lot more, like the same set (but only as a Top-10) for each year (currently 36), each type (currently 18), country (currently 29 + 1), and nationality (currently 89).

Due to the fact that the number of items to process is unknown, all data is held in linked lists, but the sort is done on an, obviously controlled, array of of pointers to the various items in said linked list. So far, so good, this works like a charm for the summary tables, just take the first 50 items, put them into a table, and "Bob's your uncle..."

Producing the other Top-nn's can use the same sorted arrays, and that's what I'm doing at the moment, and it works flawlessly, but it's not exactly efficient, as there are sets that contain just a few items, in which case, should you wonder, the Top-10 might be reduced to a Top-7, Top-3, or in rather more than a few (27!) cases, a Top-1...

And those are the ones that are highly inefficient, as I have to go through almost the entire array to find the first item using the following:

Code:
#h = hbound(distance.d_ptr, 1);
#i = #h;

do c = 'K', 'T', 'V';
  #t = 0;

  do #i = #h to lbound(distance.d_ptr, 1) by -1 until(#t = #top_nn);
    list_ptr = distance(#i).k_ptr;  /* or time.t_ptr/velocity.v_ptr */

    if sty_tcn = 'N' & tcn = this_list.nat  | /* 89     */
       sty_tcn = 'Y' & sty = this_list.year | /* 36     */
       sty_tcn = 'C' & tcn = this_list.cnty | /* 29 + 1 */
       sty_tcn = 'T' & tcn = this_list.type | /* 18     */
       sty_tcn = '*' then                     /* 1 (summary) */
      do;
        #t = #t + 1;

        if #t = 1 then
          do;
            if c = 'K' | sty_tcn = '*' then
              do;
                #h = #i;
                write file(outfile) from(pline);
                write file(outfile) from(top_nn_sep);
                write file(outfile) from(top_nn_head);
                write file(outfile) from(top_nn_sep);
              end;
          end;
        .
        .
        line           = top_nn_init;
        top_nn_line    = this_list, by name;
        top_nn_line.v  = round(this_list.vx, 1);
        .
        .
      end;
  end;
end;

I do a little bit of caching (actually a hell of a lot for the what turn out to be the Top-1 tables) by saving #i in #h for #t = 1 & c = 'K', but can someone suggest an even more efficient way. And no I don't want to sort individual sub-lists, as that's more than likely going to cost way more CPU than the current approach.

Any ideas?

Thanks!
Back to top
View user's profile Send private message

View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. how to code for GDG in Rexx cvnlynn CLIST & REXX 13 Wed Aug 09, 2017 9:13 pm
This topic is locked: you cannot edit posts or make replies. rexx code to create a ps file Bharath Vikraman CLIST & REXX 4 Mon Aug 07, 2017 10:30 am
No new posts I want to retire TRX and use only Rex... Abhinav Sharma CLIST & REXX 6 Sat Jul 29, 2017 2:53 am
No new posts UNIT=AFF for Easytrieve code gandikk JCL & VSAM 7 Wed Jul 12, 2017 11:42 pm
No new posts Reduce CPU Times for Join Sort santoshn SYNCSORT 12 Sat Jun 10, 2017 1:40 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us