For Programmers: Free Programming Magazines  


Home > Archive > Cobol > September 2007 > COBOL "non-myth" confirmed - Index and subscripts (MF on Windows)









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author COBOL "non-myth" confirmed - Index and subscripts (MF on Windows)
William M. Klein

2007-09-13, 6:55 pm

I do not have a Unix or Linux environment to test this on, but I did create a
program to test subscripts vs indices with Micro Focus Net Express 5.0 (Warp 03)
on Windows. The following programs (one a driver to run the other two)
confirmed that the program using indices in THIS environment runs about 1/3
slower with subscripts than with indices. (I tried it with the STANDARD
"Binary" and then changed it to "Comp-5". The latter, non-portable version runs
a little faster and is listed below - but is still measurably slower than the
one with indices). I would be interested in results with other compilers and/or
environments. (Change COMP-5 to BINARY if required. Otherwise, I think it is
sully '85 Standard - with Intrinsic Functions - conforming).

(Hopefully "indentation" etc will stay OK. If not, let me know and I'll put the
source programs on the web for download.

Driver Program:

Identification Division.

Program-Id. IndSub.

Procedure Division.

Mainline.

Call "TstSub"

Call "TstInd"

Stop Run

Daeraneermap9

2007-09-13, 7:13 pm

oral hardcore, oral girls, porno video, oral granny, blow adult, amateur porn, sex pics, oral movie clips, ghinzu blow, XXXX movie, oral asian, gay porn, bondage, oral porn, oral XXXXing, pornstars, adult movies.

girls blow
William M. Klein

2007-09-14, 3:55 am

Just wanted to reply to my own note with an update (and possible CORRECTION).

I realized that I had run my test in ".INT" not ".EXE". When I compiled to exe
and reran a few times, the results were different. The two programs ran ABOUT
the same (I ran them several times). In fact, the subscript ran faster more
times than the index version. Seems that there is either a "myth" involved or
that there is some other factor that I am not testing (correctly) for.

--
Bill Klein
wmklein <at> ix.netcom.com
"William M. Klein" <wmklein@nospam.netcom.com> wrote in message
news:wzjGi.64367$gR1.27555@fe03.news.easynews.com...
>I do not have a Unix or Linux environment to test this on, but I did create a
>program to test subscripts vs indices with Micro Focus Net Express 5.0 (Warp
>03) on Windows. The following programs (one a driver to run the other two)
>confirmed that the program using indices in THIS environment runs about 1/3
>slower with subscripts than with indices. (I tried it with the STANDARD
>"Binary" and then changed it to "Comp-5". The latter, non-portable version
>runs a little faster and is listed below - but is still measurably slower than
>the one with indices). I would be interested in results with other compilers
>and/or environments. (Change COMP-5 to BINARY if required. Otherwise, I think
>it is sully '85 Standard - with Intrinsic Functions - conforming).
>
> (Hopefully "indentation" etc will stay OK. If not, let me know and I'll put
> the source programs on the web for download.
>
> Driver Program:
>
> Identification Division.
>
> Program-Id. IndSub.
>
> Procedure Division.
>
> Mainline.
>
> Call "TstSub"
>
> Call "TstInd"
>
> Stop Run
>
> .
>
>
>
> * * * * * * * *
>
> Test Indices
>
>
>
> Identification Division.
>
> Program-ID. TstInd.
>
> Data Division.
>
> Working-Storage Section.
>
> 01 Time-Flds.
>
> 05 Start-Time Pic X(08).
>
> 05 End-Time Pic X(08).
>
> 05 Temp-Time.
>
> 10 Pic X.
>
> 10 M-Dig2 Pic 9.
>
> 10 Pic X.
>
> 10 S-Dig2 Pic 9.
>
> 10 H-Dig1 Pic 9.
>
> 10 H-Dig2 Pic 9.
>
> 01 TabA.
>
> 05 Tabl1A occurs 10 Times
>
> indexed by Ind1a.
>
> 10 T1A Pic X(03).
>
> 10 Tabl2A Occurs 10 Times
>
> Indexed by Ind2a.
>
> 15 T2A Pic X(33).
>
> 15 Tabl3A Occurs 10 Times
>
> Indexed by Ind3A.
>
> 20 T3a Pic X.
>
> 20 Tabl4A Occurs 10 times
>
> Indexed by Ind4a.
>
> 25 T4A Pic X(11).
>
> 25 ElemA Pic X(300).
>
> 15 T2AA Pic X.
>
> 10 T1AA Pic X(5).
>
> 01 Tabb.
>
> 05 Tabl1b occurs 10 Times
>
> indexed by Ind1b.
>
> 10 T1b Pic X(11).
>
> 10 Tabl2b Occurs 10 Times
>
> Indexed by Ind2b.
>
> 15 T2b Pic X(22).
>
> 15 Tabl3b Occurs 10 Times
>
> Indexed by Ind3b.
>
> 20 T3b Pic X(05).
>
> 20 Tabl4b Occurs 10 times
>
> Indexed by Ind4b.
>
> 25 T4b Pic X(11).
>
> 25 Elemb Pic X(300).
>
> 15 T2bb Pic X(11).
>
> 10 T1bb Pic X(3).
>
>
>
> Procedure Division.
>
> Mainline.
>
> Move Function Current-Date (9:8) to Start-Time
>
> Perform Loop 500000 Times
>
> Move Function Current-Date (9:8) to End-Time
>
> Display " *** Testing Indices * * *"
>
> Display "Start-Time:"
>
> Start-Time (1:2) ":"
>
> Start-Time (3:2) ":"
>
> Start-Time (5:2) "."
>
> Start-Time (7:2)
>
> Display " End-Time:"
>
> End-Time (1:2) ":"
>
> End-Time (3:2) ":"
>
> End-Time (5:2) "."
>
> End-Time (7:2)
>
> .
>
> If-Called.
>
> Exit Program
>
> .
>
> If-Main.
>
> Stop Run
>
> .
>
> Loop.
>
> Move Function Current-Date (11:6) to Temp-Time
>
> Set Ind1a to M-Dig2
>
> Set Ind2a to S-Dig2
>
> Set Ind3a to H-Dig1
>
> Set Ind4a to H-Dig2
>
> Set Ind1A up by 1
>
> Set Ind2a up by 1
>
> Set Ind3a up by 1
>
> Set Ind4a up by 1
>
> Move High-Values to ElemA (Ind1a Ind2a Ind3a Ind4a)
>
> Set Ind2b to M-Dig2
>
> Set Ind4b to S-Dig2
>
> Set Ind1b to H-Dig1
>
> Set Ind3b to H-Dig2
>
> Set Ind1b up by 1
>
> Set Ind2b up by 1
>
> Set Ind3b up by 1
>
> Set Ind4b up by 1
>
> Move ElemA (Ind1a Ind2a Ind3a Ind4a) to
>
> ElemB (Ind1b Ind2b Ind3b Ind4b)
>
> .
>
> * * * * * * * *
>
> Test Subscripts:
>
>
>
> Identification Division.
>
> Program-ID. TstSub.
>
> Data Division.
>
> Working-Storage Section.
>
> 01 Time-Flds.
>
> 05 Start-Time Pic X(08).
>
> 05 End-Time Pic X(08).
>
> 05 Temp-Time.
>
> 10 Pic X.
>
> 10 M-Dig2 Pic 9.
>
> 10 Pic X.
>
> 10 S-Dig2 Pic 9.
>
> 10 H-Dig1 Pic 9.
>
> 10 H-Dig2 Pic 9.
>
> 01 TabA.
>
> 05 Tabl1A occurs 10 Times
>
> indexed by Ind1a.
>
> 10 T1A Pic X(03).
>
> 10 Tabl2A Occurs 10 Times
>
> Indexed by Ind2a.
>
> 15 T2A Pic X(33).
>
> 15 Tabl3A Occurs 10 Times
>
> Indexed by Ind3A.
>
> 20 T3a Pic X.
>
> 20 Tabl4A Occurs 10 times
>
> Indexed by Ind4a.
>
> 25 T4A Pic X(11).
>
> 25 ElemA Pic X(300).
>
> 15 T2AA Pic X.
>
> 10 T1AA Pic X(5).
>
> 01 Tabb.
>
> 05 Tabl1b occurs 10 Times
>
> indexed by Ind1b.
>
> 10 T1b Pic X(11).
>
> 10 Tabl2b Occurs 10 Times
>
> Indexed by Ind2b.
>
> 15 T2b Pic X(22).
>
> 15 Tabl3b Occurs 10 Times
>
> Indexed by Ind3b.
>
> 20 T3b Pic X(05).
>
> 20 Tabl4b Occurs 10 times
>
> Indexed by Ind4b.
>
> 25 T4b Pic X(11).
>
> 25 Elemb Pic X(300).
>
> 15 T2bb Pic X(11).
>
> 10 T1bb Pic X(3).
>
>
>
> 01 Subs.
>
> 05 Sub1a Pic S9(04) Comp-5.
>
> 05 Sub2a Pic S9(04) Comp-5.
>
> 05 Sub3a Pic S9(04) Comp-5.
>
> 05 Sub4a Pic S9(04) Comp-5.
>
> 05 Sub1b Pic S9(04) Comp-5.
>
> 05 Sub2b Pic S9(04) Comp-5.
>
> 05 Sub3b Pic S9(04) Comp-5.
>
> 05 Sub4b Pic S9(04) Comp-5.
>
>
>
> Procedure Division.
>
> Mainline.
>
> Move Function Current-Date (9:8) to Start-Time
>
> Perform Loop 500000 Times
>
> Move Function Current-Date (9:8) to End-Time
>
> Display " * * * Testing Subscripts * * *"
>
> Display "Start-Time:"
>
> Start-Time (1:2) ":"
>
> Start-Time (3:2) ":"
>
> Start-Time (5:2) "."
>
> Start-Time (7:2)
>
> Display " End-Time:"
>
> End-Time (1:2) ":"
>
> End-Time (3:2) ":"
>
> End-Time (5:2) "."
>
> End-Time (7:2)
>
> .
>
> If-Called.
>
> Exit Program
>
> .
>
> If-Main.
>
> Stop Run
>
> .
>
> Loop.
>
> Move Function Current-Date (11:6) to Temp-Time
>
> Move M-Dig2 To Sub1a
>
> Move S-Dig2 to Sub2a
>
> Move H-Dig1 to Sub3a
>
> Move H-Dig2 to Sub4a
>
> Add 1 to Sub1a
>
> Add 1 to Sub2a
>
> Add 1 to Sub3a
>
> Add 1 to Sub4a
>
> Move High-Values to ElemA (Sub1a Sub2a Sub3a Sub4a)
>
> Move M-Dig2 To Sub1b
>
> Move S-Dig2 to Sub2b
>
> Move H-Dig1 to Sub3b
>
> Move H-Dig2 to Sub4b
>
> Add 1 to Sub1b
>
> Add 1 to Sub2b
>
> Add 1 to Sub3b
>
> Add 1 to Sub4b
>
> Move ElemA (Sub1a Sub2a Sub3a Sub4a) to
>
> ElemB (Sub1b Sub2b Sub3b Sub4b)
>
> .
>
>
>
>
> --
> Bill Klein
> wmklein <at> ix.netcom.com
>



William M. Klein

2007-09-14, 3:55 am

And one final note, Robert never claimed that Micro Focus documented Indices as
faster than Subscripts (for their product). He only included this as a "legacy"
belief.

--
Bill Klein
wmklein <at> ix.netcom.com
"William M. Klein" <wmklein@nospam.netcom.com> wrote in message
news:munGi.147731$1J4.20682@fe06.news.easynews.com...
> Just wanted to reply to my own note with an update (and possible CORRECTION).
>
> I realized that I had run my test in ".INT" not ".EXE". When I compiled to
> exe and reran a few times, the results were different. The two programs ran
> ABOUT the same (I ran them several times). In fact, the subscript ran faster
> more times than the index version. Seems that there is either a "myth"
> involved or that there is some other factor that I am not testing (correctly)
> for.
>
> --
> Bill Klein
> wmklein <at> ix.netcom.com
> "William M. Klein" <wmklein@nospam.netcom.com> wrote in message
> news:wzjGi.64367$gR1.27555@fe03.news.easynews.com...
>
>



Robert

2007-09-15, 3:55 am

On Fri, 14 Sep 2007 03:46:30 GMT, "William M. Klein" <wmklein@nospam.netcom.com> wrote:

>Just wanted to reply to my own note with an update (and possible CORRECTION).
>
>I realized that I had run my test in ".INT" not ".EXE". When I compiled to exe
>and reran a few times, the results were different. The two programs ran ABOUT
>the same (I ran them several times). In fact, the subscript ran faster more
>times than the index version. Seems that there is either a "myth" involved or
>that there is some other factor that I am not testing (correctly) for.


You have the overhead of getting the time inside the loop. I suggest you run an third test
with nothing but getting the time inside the loop and perform varying outside. That time
is constant for all tests. Subtract it from the time measured to get the time of activity
you're measuring.

By setting the index on each iteration, you're negating any possible difference between
index and subscript. The basic difference is that subscript requires multiplication
whereas index does not. SETTING an index does a multiplication, same as USING a subscript.
I'm not surprised times are the same.

The most common use for subscripts and indexes is sequentially stepping through the
elements of a table, not accessing them randomly.


Robert

2007-09-15, 3:55 am

On Fri, 14 Sep 2007 04:02:14 GMT, "William M. Klein" <wmklein@nospam.netcom.com> wrote:

>And one final note, Robert never claimed that Micro Focus documented Indices as
>faster than Subscripts (for their product). He only included this as a "legacy"
>belief.


Speed is the only reason indexes are used. If people didn't think indexes were faster,
they'd never use indexes (except SEARCH ALL, the one case where required).
William M. Klein

2007-09-15, 3:55 am


"Robert" <no@e.mail> wrote in message
news:3iime3d7d8fjn6abr5dic1a47cr1mnk8va@
4ax.com...
> On Fri, 14 Sep 2007 04:02:14 GMT, "William M. Klein"
> <wmklein@nospam.netcom.com> wrote:
>
>
> Speed is the only reason indexes are used. If people didn't think indexes were
> faster,
> they'd never use indexes (except SEARCH ALL, the one case where required).


So Robert, before I comment when you say

If people didn't think indexes were faster, they'd never use indexes (except
SEARCH ALL, the one case where required).

do you MEAN

If people (all people) didn't think indexes were faster, they'd never (in any
case or any program - except as excluded in the following parenthetical) use
indexes (except SEARCH ALL, the one case where required).

or do you mean

If people (in general, but not universally) didn't think indexes were faster,
they'd never (well RARELY) use indexes (except SEARCH ALL, the one case where
required).

It is statements like your original that make it hard for me (and I believer
others) to tell when you are trying to state a "universal truth" or when you are
stating YOUR OPINION of the GENERAL (most common) situation.

--
Bill Klein
wmklein <at> ix.netcom.com


William M. Klein

2007-09-15, 3:55 am

The test case that I created (and that did NOT prove what I initially intended
to prove) was created with setting indices and subscripts (and doing arithmetic
on them) within in each loop because I (probably erroneously - certainly not
verified on my computer) thought that this was exactly when the difference would
show up.

As far as "getting the time" within each loop - I did so in both variations so
that can't (shouldn't?) be any difference.

--
Bill Klein
wmklein <at> ix.netcom.com
"William M. Klein" <wmklein@nospam.netcom.com> wrote in message
news:B3IGi.227037$VU2.116695@fe02.news.easynews.com...
>
> "Robert" <no@e.mail> wrote in message
> news:3iime3d7d8fjn6abr5dic1a47cr1mnk8va@
4ax.com...
>
> So Robert, before I comment when you say
>
> If people didn't think indexes were faster, they'd never use indexes (except
> SEARCH ALL, the one case where required).
>
> do you MEAN
>
> If people (all people) didn't think indexes were faster, they'd never (in any
> case or any program - except as excluded in the following parenthetical) use
> indexes (except SEARCH ALL, the one case where required).
>
> or do you mean
>
> If people (in general, but not universally) didn't think indexes were faster,
> they'd never (well RARELY) use indexes (except SEARCH ALL, the one case where
> required).
>
> It is statements like your original that make it hard for me (and I believer
> others) to tell when you are trying to state a "universal truth" or when you
> are stating YOUR OPINION of the GENERAL (most common) situation.
>
> --
> Bill Klein
> wmklein <at> ix.netcom.com
>



Robert

2007-09-15, 3:55 am

On Sat, 15 Sep 2007 03:11:29 GMT, "William M. Klein" <wmklein@nospam.netcom.com> wrote:

>
>"Robert" <no@e.mail> wrote in message
> news:3iime3d7d8fjn6abr5dic1a47cr1mnk8va@
4ax.com...
>
>So Robert, before I comment when you say
>
>If people didn't think indexes were faster, they'd never use indexes (except
>SEARCH ALL, the one case where required).
>
> do you MEAN
>
>If people (all people) didn't think indexes were faster, they'd never (in any
>case or any program - except as excluded in the following parenthetical) use
>indexes (except SEARCH ALL, the one case where required).
>
> or do you mean
>
>If people (in general, but not universally) didn't think indexes were faster,
>they'd never (well RARELY) use indexes (except SEARCH ALL, the one case where
>required).


I mean the second. Interpreting unqualified "people" to mean every person without
exception is YOUR interpetation, not the meaning I intended.

>It is statements like your original that make it hard for me (and I believer
>others) to tell when you are trying to state a "universal truth" or when you are
>stating YOUR OPINION of the GENERAL (most common) situation.


Everything posted here is the writer's opinion, unless it is supported by corrigible
evidence and logic that would convince a reasonable person to believe the writer's
conclusion is justified.
Robert

2007-09-15, 3:55 am

On Sat, 15 Sep 2007 03:18:26 GMT, "William M. Klein" <wmklein@nospam.netcom.com> wrote:

>The test case that I created (and that did NOT prove what I initially intended
>to prove) was created with setting indices and subscripts (and doing arithmetic
>on them) within in each loop because I (probably erroneously - certainly not
>verified on my computer) thought that this was exactly when the difference would
>show up.


SET convrts an ordinal (1, 2, 3) into an offset. The same conversion occurs when you USE a
subscript.

Indexes used to be faster because they avoided that conversion on each use. They are no
longer faster because a multiply is now as fast as a load.

>As far as "getting the time" within each loop - I did so in both variations so
>that can't (shouldn't?) be any difference.


It certainly can. Suppose it takes 50 time units to get the time, 10 time units to drive
the loop, 20 time units to execute test code A, 40 time units to execute code B.

The correct answer is that A is twice as fast as B (40 / 20). The answer you will get is

A time = 50 + 10 + 20 = 80
B time = 50 + 10 + 40 = 100

A is 25% faster than B.

You'd be off by a factor of 4.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com