Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: What's the point of remarks?  (Read 15901 times)

0 Members and 1 Guest are viewing this topic.

Dias de verano

  • Guest
Re: What's the point of remarks?
« Reply #15 on: January 17, 2009, 02:40:20 PM »
How are you getting it to repeat 5000 times? Do you have a robot (android) that bangs on the F3 and ENTER key 5000 times? How do we know the 7 o 8 minutes are not being mostly the time it takes to hit the keys 5000 times. You did not explain how you got the batch file to do 5000 times.

Yes I did. Read the code. And its fifty thousand, not five thousand, as I have already told you.  ::)

Geek-9pm


    Mastermind
  • Geek After Dark
  • Thanked: 1026
    • Gekk9pm bnlog
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 10
Re: What's the point of remarks?
« Reply #16 on: January 17, 2009, 03:02:16 PM »
Code: [Select]
for /L %%N in (1,1,%1) do call dot.bat %%N
OK. I missed it. By beady little eyes did not see that.
Thank you.

Now the nest question is how much time was used by the loop?
Please try it again for 3 bat files the third bat file is here:
Code: [Select]

Just one blank line. Can you do that please? I what to see what the loop overhead is. This will help answer the question about remark skipping.
Due to my age I can DOS challenged, and besides, my machine will give different results.

Dias de verano

  • Guest
Re: What's the point of remarks?
« Reply #17 on: January 17, 2009, 05:09:48 PM »
1. REM   426.67 seconds
2. dots  480.02 seconds
3. empty 293.15 seconds

Geek-9pm


    Mastermind
  • Geek After Dark
  • Thanked: 1026
    • Gekk9pm bnlog
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 10
Re: What's the point of remarks?
« Reply #18 on: January 17, 2009, 05:59:20 PM »
Quote
1. REM   426.67 seconds
2. dots  480.02 seconds
3. empty 293.15 seconds

Thus one might conclude that the FOR and CALL have an overhead of about 293 seconds.
Therefor:
 Rem takes 133 seconds
 Dot takes 187 seconds
So using dots instead of REM will add 54 seconds ti the test. That represents an increase of nearly 40%   :o
From this I would conclude that you want to document your program, use REM rather that the dots. Unless you want to slow down your batch.

BC_Programmer


    Mastermind
  • Typing is no substitute for thinking.
  • Thanked: 1140
    • Yes
    • Yes
    • BC-Programming.com
  • Certifications: List
  • Computer: Specs
  • Experience: Beginner
  • OS: Windows 11
Re: What's the point of remarks?
« Reply #19 on: January 17, 2009, 07:14:26 PM »
And Dias already pointed out a much better reason in the other thread. Even if :: was faster, it breaks with for and command extensions. In which case code that is slower is better then code that doesn't work.

It doesn't matter how fast your code is if it doesn't work.


But- :: is slower. I imagine the command processor needs to do extra processing to try to interpret it as a line label.

besides. None of this discussion is even relevant:

People who want speed don't use batch files.


Hello!

What's the point of remarks as I see no use in them?

Is it just like if someone is editing, it tells what it is? I don't know, please help :O.

BR

have you ever come back to your own (uncommented) code 5 years down the road? Obviously not. There is a point where comments are stupid- here is useless documentation:

Code: [Select]
REM perform copy command.
copy %source1% %dest1%

It states the obvious. The code is self-documenting without the remark.

The only time one should try to comment is for complicated constructs; portions of code that aren't self-documenting. That in and of itself says that every line of Perl code needs 3 comments explaining it. Unfortunately Perl programmers usually come from a *nix background where unfortunately commenting code is regarded as a sign of weakness.



I was trying to dereference Null Pointers before it was cool.

Geek-9pm


    Mastermind
  • Geek After Dark
  • Thanked: 1026
    • Gekk9pm bnlog
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 10
Re: What's the point of remarks?
« Reply #20 on: January 17, 2009, 08:54:55 PM »
Code: [Select]
Unfortunately Perl programmers usually come from a
*nix background where unfortunately commenting code is
regarded as a sign of weakness.

NOT documenting code is a weakness.
Never have such a person on your team.

Dias de verano

  • Guest
Re: What's the point of remarks?
« Reply #21 on: January 18, 2009, 05:58:25 AM »
OK folks. Way back in the day, when a Commodore 64 was considered a
powerful computer, people used to say that comments slowed down
interpreted BASICs, and those machines were so slow that it really made
a difference.

Another thing: anybody can create a benchmark program that does not
actually do anything useful. Real world programs that people create
to do useful tasks are something else. File and text processing are
typical batch tasks.

So:

In a folder, I created

10 text files containing the phrase "horse and pony"

Quote
I used to convert wmv to avi using TMPGEnc Express 3 or 4.   More
recently I have been using VirtualDub, which, theoretically, cannot
handle wmv files but can be fooled into doing so.   You have to have
the latest ffdshow software loaded - search for
ffdshow_beta5_rev2033_20080705_clsid.ex e - and then use Notepad to
create a .avs file of the form:

DirectShowSource("C:\Conversions\file.wmv")

- obviously change the path in quotes to fit your path to file.

Open the .avs file in VDub and then you can do a Fast Re-compress,
setting the bit-rate in the XviD or DivX set-up screens to the same as
for the wmv file. I love my horse and pony.

Conversions this way are as good, quality wise as with TMPGEnc but
take a fraction of the time.

Of course, either way, you have to have the XviD and/or DivX codecs

... and 10 text files without the phrase.

Quote
I used to convert wmv to avi using TMPGEnc Express 3 or 4.   More
recently I have been using VirtualDub, which, theoretically, cannot
handle wmv files but can be fooled into doing so.   You have to have
the latest ffdshow software loaded - search for
ffdshow_beta5_rev2033_20080705_clsid.ex e - and then use Notepad to
create a .avs file of the form:

DirectShowSource("C:\Conversions\file.wmv")

- obviously change the path in quotes to fit your path to file.

Open the .avs file in VDub and then you can do a Fast Re-compress,
setting the bit-rate in the XviD or DivX set-up screens to the same as
for the wmv file.

Conversions this way are as good, quality wise as with TMPGEnc but
take a fraction of the time.

Of course, either way, you have to have the XviD and/or DivX codecs

2. Then I created a typical batch file to process all the .txt files in the folder
and show which files contained the phrase.

I created 3 versions

(a) with a typical (I feel) number of REMs, that is, the number I would put in
if I was explaining my ideas to another person.

Code: [Select]
@echo off
REM Find lines in text files
REM Containing a phrase

REM Store phrase in variable
set phrase=horse and pony

REM Loop through all .txt files in folder
REM Use FIND to check for phrase in each file

set /a foundcount=0
for /f "delims=" %%F in ('dir /b *.txt') do (
type "%%F" | find /I "%phrase%">nul && (
echo Phrase: %phrase% was found in file: %%F
set /a foundcount+=1
)
)
REM Display count of phrases found
Echo found: %foundcount%

(b) with double colons instead of REMs

Code: [Select]
@echo off
:: Find lines in text files
:: Containing a phrase

:: Store phrase in variable
set phrase=horse and pony

:: Loop through all .txt files in folder
:: Use FIND to check for phrase in each file

set /a foundcount=0
for /f "delims=" %%F in ('dir /b *.txt') do (
type "%%F" | find /I "%phrase%">nul && (
echo Phrase: %phrase% was found in file: %%F
set /a foundcount+=1
)
)
:: Display count of phrases found
Echo found: %foundcount%

(c) with no remarks at all

Code: [Select]
@echo off
set phrase=horse and pony
set /a foundcount=0
for /f "delims=" %%F in ('dir /b *.txt') do (
type "%%F" | find /I "%phrase%">nul && (
echo Phrase: %phrase% was found in file: %%F
set /a foundcount+=1
)
)
Echo found: %foundcount%

Then I ran them 1, 10, 25, 50 and 100 times each

REM = batch with REM remarks
CLN = batch with double colon remarks
NOC = batch with no remarks at all

1 run - not surprisingly, identical results, as the number of runs
grows, any differences may become apparent...

REM elapsed 3 seconds
CLN elapsed 3 seconds
NOC elapsed 3 seconds

10 runs

REM elapsed 30 seconds
CLN elapsed 34 seconds
NOC elapsed 28 seconds

25 runs

REM elapsed 82 seconds
CLN elapsed 76 seconds
NOC elapsed 75 seconds

50 runs

REM elapsed 154 seconds
CLN elapsed 154 seconds
NOC elapsed 156 seconds

100 runs

REM elapsed 286 seconds
CLN elapsed 313 seconds
NOC elapsed 313 seconds

As you can see, there ain't much in it, and any delay from
remarks is (heavily) swamped by other things.

While all these runs were taking place, my computer being a real
world computer, I was also

-using Mencoder to save a web tv ASF stream into an mpeg file
-using Xnews to download a bunch of binaries from a news server
-using Firefox to browse the web

My PC is a Shuttle ST62K with a 3.0 GHz P4 hyperthreading (Prescott core) with 1 GB RAM and a 7200 rpm IDE HD



Geek-9pm


    Mastermind
  • Geek After Dark
  • Thanked: 1026
    • Gekk9pm bnlog
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 10
Re: What's the point of remarks?
« Reply #22 on: January 18, 2009, 09:22:13 AM »
Quote
As you can see, there ain't much in it, and any delay from
remarks is (heavily) swamped by other things.

You made your point very well.
No problem with REM. Case Closed.  ;D

BC_Programmer


    Mastermind
  • Typing is no substitute for thinking.
  • Thanked: 1140
    • Yes
    • Yes
    • BC-Programming.com
  • Certifications: List
  • Computer: Specs
  • Experience: Beginner
  • OS: Windows 11
Re: What's the point of remarks?
« Reply #23 on: January 18, 2009, 09:43:40 AM »
And Compiled languages don't compile remarks so comment away!  :P
I was trying to dereference Null Pointers before it was cool.

Geek-9pm


    Mastermind
  • Geek After Dark
  • Thanked: 1026
    • Gekk9pm bnlog
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 10
Re: What's the point of remarks?
« Reply #24 on: January 18, 2009, 01:02:32 PM »
Code: [Select]
And Compiled languages don't compile remarks so comment away!
True. In some cases that may change the results.
Look at this:

Code: [Select]
echo on
REM In this operation we have %1 as the source and
REM item %2 will be the destination. This is subject to  the %3 option.
:: ...  more code
echo off

What happens if you compile that  ???
I have no idea. Never compiled a batch file!  :P

macdad-



    Expert

    Thanked: 40
    Re: What's the point of remarks?
    « Reply #25 on: January 18, 2009, 04:53:51 PM »
    the OP hasn't responded back....  ::)
    If you dont know DOS, you dont know Windows...

    Thats why Bill Gates created the Windows NT Family.

    BatchRocks

      Topic Starter


      Hopeful
    • Thanked: 3
      Re: What's the point of remarks?
      « Reply #26 on: January 18, 2009, 04:57:12 PM »
      Hi thar? I don't know what you guys are talking about, so I was just watching.

      Geek-9pm


        Mastermind
      • Geek After Dark
      • Thanked: 1026
        • Gekk9pm bnlog
      • Certifications: List
      • Computer: Specs
      • Experience: Expert
      • OS: Windows 10
      Re: What's the point of remarks?
      « Reply #27 on: January 18, 2009, 05:22:03 PM »
      OK. Now the question is :
      What happens to the REM statements if you compile a Batch file?
      The REM statements can echo different things, depends on the context.
      The REM statements are parsed like anything else.

      BC_Programmer


        Mastermind
      • Typing is no substitute for thinking.
      • Thanked: 1140
        • Yes
        • Yes
        • BC-Programming.com
      • Certifications: List
      • Computer: Specs
      • Experience: Beginner
      • OS: Windows 11
      Re: What's the point of remarks?
      « Reply #28 on: January 18, 2009, 06:15:33 PM »
      OK. Now the question is :
      What happens to the REM statements if you compile a Batch file?
      The REM statements can echo different things, depends on the context.
      The REM statements are parsed like anything else.


      you cannot compile a batch file.

      the so-called "compilers" simply plop a stub in front of a batch in a exe and call it good. The better ones compress the EXE afterwards. The REALLY good ones turn it into asm, but even then- they don't work with the extended syntax.
      I was trying to dereference Null Pointers before it was cool.

      BatchFileCommand



        Hopeful
      • Thanked: 1
        Re: What's the point of remarks?
        « Reply #29 on: January 19, 2009, 08:47:56 AM »
        Code: [Select]
        The REALLY good ones turn it into asm

        Is that even more complicated then EXE  :D?!?
        οτη άβγαλτος μεταφ βαθμολογία