Board index » delphi » Program Speed

Program Speed

Hi there,
I have a 386/DX and have recently written a program for a school project.  I
luckily tested it out on a Windows 95 computer before handing it in, since
it was probably most likely to be tested on one.  My program used speaker
sound, and much to my distress, I found that the sound was much to fast.
Because I used Delay(ms), I guessed that the problem was to be found in the
clock speed difference.  I then hastily added another delay that multiplied
each Delay(ms) by a number specified by the user on start up.  

I am now writing my Gr 11 end of year project, and I would not like to go
through something similar again.  Is there a way to auto-detect the speed
of the computer?  What would you suggest? (save buying a faster computer :) )
What about this:
 Speed Test Procedure
 1. Get current time, save in variable oldtime
 2. Repeat inc(i); Until i > number
 3. Get new time, save in newtime
 4. time diffrence := newtime - oldtime
 5 Case time diffrence of
   Begin
    5 : multiply := 2;
   End;
 End Speed Test

How do I get the current time in TP 6.0?  Is there a better way?

Thanks in advance.

 Groete uit Suid-Afrika        -              
 Greetings from South Africa   -          Johan Khler
 Salutojn de Sud-Afriko        -          johan.koh...@als.co.za
___ Blue Wave/DOS v2.30 [NR]

 

Re:Program Speed


Quote
JOHAN KOHLER wrote:

> Hi there,
> I have a 386/DX and have recently written a program for a school project.  I
> luckily tested it out on a Windows 95 computer before handing it in, since
> it was probably most likely to be tested on one.  My program used speaker
> sound, and much to my distress, I found that the sound was much to fast.
> Because I used Delay(ms), I guessed that the problem was to be found in the
> clock speed difference.  I then hastily added another delay that multiplied
> each Delay(ms) by a number specified by the user on start up.

> I am now writing my Gr 11 end of year project, and I would not like to go
> through something similar again.  Is there a way to auto-detect the speed
> of the computer?  What would you suggest? (save buying a faster computer :) )
> What about this:
>  Speed Test Procedure
>  1. Get current time, save in variable oldtime
>  2. Repeat inc(i); Until i > number
>  3. Get new time, save in newtime
>  4. time diffrence := newtime - oldtime
>  5 Case time diffrence of
>    Begin
>     5 : multiply := 2;
>    End;
>  End Speed Test

> How do I get the current time in TP 6.0?  Is there a better way?

> Thanks in advance.

>  Groete uit Suid-Afrika        -
>  Greetings from South Africa   -          Johan Khler
>  Salutojn de Sud-Afriko        -          johan.koh...@als.co.za
> ___ Blue Wave/DOS v2.30 [NR]

hello there,
ofcourse you will get different speed results if you use a delay....
that's why all the module players work with dma and irq's....
you can get free sources of those ( for example : midas sound system ),
on ftp://ftp.cdrom.com
an other way would be to use the interrupt timer which you can put
at a specific number of times per second...those are stable on
any system :)

greets from Gert-Jan Bark ( game coder ) email : b...@cs.utwente.nl

Re:Program Speed


Quote
JOHAN KOHLER wrote:

> Hi there,
> I have a 386/DX and have recently written a program for a school project.  I
> luckily tested it out on a Windows 95 computer before handing it in, since
> it was probably most likely to be tested on one.  My program used speaker
> sound, and much to my distress, I found that the sound was much to fast.
> Because I used Delay(ms), I guessed that the problem was to be found in the
> clock speed difference.  I then hastily added another delay that multiplied
> each Delay(ms) by a number specified by the user on start up.

> I am now writing my Gr 11 end of year project, and I would not like to go
> through something similar again.  Is there a way to auto-detect the speed
> of the computer?  What would you suggest? (save buying a faster computer :) )
> What about this:
>  Speed Test Procedure
>  1. Get current time, save in variable oldtime
>  2. Repeat inc(i); Until i > number
>  3. Get new time, save in newtime
>  4. time diffrence := newtime - oldtime
>  5 Case time diffrence of
>    Begin
>     5 : multiply := 2;
>    End;
>  End Speed Test

> How do I get the current time in TP 6.0?  Is there a better way?

> Thanks in advance.

>  Groete uit Suid-Afrika        -
>  Greetings from South Africa   -          Johan Khler
>  Salutojn de Sud-Afriko        -          johan.koh...@als.co.za
> ___ Blue Wave/DOS v2.30 [NR]

Best thing: get TP7.0 or use one of the delay-procedures you can find on
the net (including this newsgroup). The thing is that the
delay-procedure in TP6.0 has a bug - it isn't reliable.

Remco de Korte
Soft Machine
Nederland
http://yi.com/home/DekorteRemco/ (games, games, games - from the old
days)

Re:Program Speed


Quote
johan.koh...@als.co.za (JOHAN KOHLER) wrote:
>Hi there,
>I have a 386/DX and have recently written a program for a school project.  I
>luckily tested it out on a Windows 95 computer before handing it in, since
>it was probably most likely to be tested on one.  My program used speaker
>sound, and much to my distress, I found that the sound was much to fast.
>Because I used Delay(ms), I guessed that the problem was to be found in the
>clock speed difference.  I then hastily added another delay that multiplied
>each Delay(ms) by a number specified by the user on start up.  

>I am now writing my Gr 11 end of year project, and I would not like to go
>through something similar again.  Is there a way to auto-detect the speed
>of the computer?  What would you suggest? (save buying a faster computer :) )

The solution you describe is similar to what the CRT delay does.
If you go this route remember to make the code that calibrates the
same as the code that counts the delay.

Another solution would be to use Frank Heckenbach's NewDelay at
http://www.mi.uni-erlangen.de/~heckenb/programs.htm#NewDelay or
compile your program with the TP 4.0 to 7.0 compatible runtime
patch at http://users.southeast.net/~rdonais/index.html

The problem is that earlier versions of TP used a word to
calibrate the delay.  The word overflows on faster machines and
results in unpredictable delays.  TP 7.0 uses a 32-bit integer.
However it too fails on machines like a P200, usually with a
divide by zero error.

Frank and I approached the problem two different ways.  I sure
you'll find one or the other solution to your liking.  

Guess TP 3.0 users are the only ones w/o a solution.  Anyone care
for a TP 3.0 fix?

    ...red

Re:Program Speed


 -=> Quoting Nicole Jansen to All <=-

 NJ> an other way would be to use the interrupt timer which you can put
 NJ> at a specific number of times per second...those are stable on
 NJ> any system :)

 Can you please give an example of this.  I am ASM illiterate.
 Thanks in advance.
 Johan

 Groete uit Suid-Afrika        -              
 Greetings from South Africa   -          Johan Khler
 Salutojn de Sud-Afriko        -          johan.koh...@als.co.za
___ Blue Wave/DOS v2.30 [NR]

Re:Program Speed


 Hi there,

 RDK> Best thing: get TP7.0 or use one of the delay-procedures you can find
 RDK> on the net (including this newsgroup). The thing is that the
 RDK> delay-procedure in TP6.0 has a bug - it isn't reliable.

 You haven't perhaps got an example of a delay-procedure?  I don't have
 net-access, but if you can get me a specific address I can get it by
 e-mail.
 Thanks in advance.

 Groete uit Suid-Afrika        -              
 Greetings from South Africa   -          Johan Khler
 Salutojn de Sud-Afriko        -          johan.koh...@als.co.za
___ Blue Wave/DOS v2.30 [NR]

Re:Program Speed


Quote
JOHAN KOHLER wrote:

>  -=> Quoting Nicole Jansen to All <=-

>  NJ> an other way would be to use the interrupt timer which you can put
>  NJ> at a specific number of times per second...those are stable on
>  NJ> any system :)

>  Can you please give an example of this.  I am ASM illiterate.
>  Thanks in advance.
>  Johan

>  Groete uit Suid-Afrika        -
>  Greetings from South Africa   -          Johan Khler
>  Salutojn de Sud-Afriko        -          johan.koh...@als.co.za
> ___ Blue Wave/DOS v2.30 [NR]

Hi Johan, i saw your request about the timing stuff, and that's why
i uploaded my fourier-mod-player in pascal to ftp.cdrom.com,
you should go to :
ftp://ftp.cdrom.com/pub/demos/incoming/code/
and then there are 2 files : fourier.txt ( with the basic info
of my program, and fourier.zip ( the program you are looking for ).
If everything is allright i put all the files in there which you
need. My program plays a general ( old fashioned ) mod file
( only 4 channels ). It sure doesn't support all the mod files
around, 'cause i didn't take much time to make it perfect, but
you will find there the way about the timing......
please write email to snip...@freemail.nl for comments or
questions about the program or this letter...

signed : snipdag ( aka gert-jan bark ) snip...@freemail.nl

Other Threads