Re: type string
Well, I tried adding your type to the benchmark I've been using (a =
modification of Jeffrey's). It is the fastest, except when you replace =
's[i]' with 'c' in Jeff's string type #3... then it falls to second =
place.
For the record, I ran the benchmark a few times, 100,000 iterations per =
type, under full-screen DOS from within Windows 95. The results are =
still consistent, though.
Hmm... wait a second...
Even better. By rearranging the code in string type #3 (to remove the =
'not' of the integer check), the speed has been increased slightly more, =
although only noticeable for longer strings. At first I was still doing =
those checks for an invalid string--but removing them doesn't seem to =
change things much...
Here's Jeff's winning (modified) string type:
global type string6(object s)
object c
if not sequence(s) then
return 0
end if
for i =3D 1 to length(s) do
c =3D s[i]
if integer(c) then
if (c < 0) or (c > 255) then
return 0
end if
else
return 0
end if
end for
return 1
end type
Rod Jackson
----------
From: Daniel Berstein[SMTP:daber at PAIR.COM]
Sent: Thursday, March 11, 1999 7:42 PM
To: EUPHORIA at LISTSERV.MUOHIO.EDU
Subject: Re: type string
<<File: ATT00000.txt>><<File: ATT00001.txt>>
Here's my record breaking string type check:
global type string5(object s)
object c
if not sequence(s) then
return 0
end if
for j =3D 1 to length(s) do
c =3D s[j]
if sequence(c) or floor(c/255) or not c then
return 0
end if
end for
return 1
end type
Attached is the source of my benchmark code. It's open to add new =
routines
for measurment, look on source where to put your type definition and =
where
to "hook" it to the benchmark (near the end of the file).
Please someone running plain DOS verify my results, Windows NT seem to =
not
like too much tick_rate(). I had to use ridiculus values (1.000.000) to
obtain cuantifiable values! I suggest as a reasonable test 100.000
iterations 5 times (ex strbench 100000 5).
|
Not Categorized, Please Help
|
|