News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Sorting strings

Started by RuiLoureiro, May 29, 2014, 06:15:48 AM

Previous topic - Next topic

RuiLoureiro

 :biggrin:
Hi
    Does anyone know a procedure/macro to generate random strings ?
    Do you want to write it ?
      :t


    EDIT: i wrote something about it.       

jj2007

Something like this?

include \masm32\MasmBasic\MasmBasic.inc      ; download
  Init
  LenMin=5
  LenMax=50
  xor esi, esi
  Dim My$()
  Let edi=New$(LenMax+1)
  .Repeat
      push edi
      add Rand(LenMax-LenMin), LenMin
      push eax
      xor ecx, ecx
      .Repeat
            add Rand(26), "a"
            stosb
            inc ecx
      .Until ecx>=stack
      pop eax
      xor eax, eax
      stosb
      pop edi
      Let My$(esi)=edi
      inc esi
  .Until esi>=1000
  Store "Random.txt", My$()
  Inkey Str$("%i strings generated", eax)
  Exit
end start

KeepingRealBusy

It is more fun if you get a spelling dictionary, and randomly select words and concatenate them to the desired random string length then terminate the line.

Dave.

dedndave

my concern is more toward the test you devise   :t

if you generate a set of random strings for a test
it's only fair if you use the same set on each routine tested
rather than generating a different set for each test run

KeepingRealBusy

Dave,

Agreed! Write the file with the random data, then test with different programs.

Dave.

RuiLoureiro

 :biggrin:
Thanks all,
                  i started to think about this yesterday but now i have some new ideas.

sinsi

Random strings? Just wait for some
"kitchen"
"k.i.t.c.h.e.n"
"k i t c h e n"
"kit chen" spam :biggrin:
That handbag one the other day was almost comprehensible.

Back on topic, do you mean random letters or words?

jj2007

Quote from: dedndave on May 29, 2014, 07:33:21 AM
it's only fair if you use the same set on each routine tested

With most pseudo-random number generators including Rand(), you get the same set anyway - unless you explicitly set a new seed. So that shouldn't be a problem.

dedndave

you can see how one set of random strings might yield very different results from another
especially seeing as you have been working on sort routines, lately   :P

hutch--

sinsi,

I am glad you approve of the method of encouraging our spamming friends to post else where.  :P

RuiLoureiro

#10
Quote from: sinsi on May 29, 2014, 07:11:35 PM
Random strings? Just wait for some
" your link does not work IDIOT "
"/\/\/\/\ BANCI /\/\/\/\"
"/ / / This was posted by an IDIOT / / /"
"kit chen" spam :biggrin:
That handbag one the other day was almost comprehensible.

Back on topic, do you mean random letters or words?

:biggrin: :biggrin:
No, like these:
"two things are infinite:"
"universe and the stupidity."
"but about the first i am not sure."
"Albert Einstein"

on topic:
             may be sets of random letters/numbers
         

RuiLoureiro

Quote from: dedndave on May 29, 2014, 07:33:21 AM
my concern is more toward the test you devise   :t

if you generate a set of random strings for a test
it's only fair if you use the same set on each routine tested
rather than generating a different set for each test run
Hi Dave,
              Yes it must be  :t

RuiLoureiro

#12
Hi
        2 procedures to compare 2 "strings
        with spaces":       
                              CompareStringXYS    <- compare DWORDS
                              CompareStringXYBS   <- compare BYTES

note that: "abcdef"  is EQUAL to "a b c d e      F"
                  For example, many times, we have product names which name
                  is nearly EQUAL. And they have spaces between words.

        Could you post your results ?
        Thanks

Jochen,
              add some other procedures that you know
              and test it.
              Thanks  :t

Strings used:

Quote
_string01X       db "a bcd efg hij klm nop",0
_string01Y       db "ab cdefg hijk lmnopA",0    <-- equal X+ 'A'

_string02X       db "abc de fghijkl mn op",0
_string02Y       db "abc defg hi jk lm nop",0   <--- equal X

_string03X       db "abc de fghijkl mn op A",0  <--- equal Y+ 'A'
_string03Y       db "abc defg hi jk lm nop",0

Results:
Quote
STRINGS:
a bcd efg hij klm nop
ab cdefg hijk lmnopA

abc de fghijkl mn op
abc defg hi jk lm nop

abc de fghijkl mn op A
abc defg hi jk lm nop

X is less than Y
ShowResultXY
X is EQUAL Y
ShowResultXY
X is greater than Y
ShowResultXY
X is less than Y
ShowResultXY
X is EQUAL Y
ShowResultXY
X is greater than Y
ShowResultXY
132 milliseconds, CompareStringXYS, _string01X, _string01Y
121 milliseconds, CompareStringXYS, _string02X, _string02Y
137 milliseconds, CompareStringXYS, _string03X, _string03Y
158 milliseconds, CompareStringXYBS, _string01X, _string01Y
152 milliseconds, CompareStringXYBS, _string02X, _string02Y
159 milliseconds, CompareStringXYBS, _string03X, _string03Y
*** Press any key to get the time table ***

***** Time table *****
121 milliseconds, CompareStringXYS -_string02X EQUAL _string02Y-16 bytes
132 milliseconds, CompareStringXYS -_string01X LESS _string01Y-16 bytes
137 milliseconds, CompareStringXYS -_string03X GREATER _string03Y-16 bytes
152 milliseconds, CompareStringXYBS -_string02X EQUAL _string02Y-16 bytes
158 milliseconds, CompareStringXYBS -_string01X LESS _string01Y-16 bytes
159 milliseconds, CompareStringXYBS -_string03X GREATER _string03Y-16 bytes
********** END 2 **********

jj2007

Quote from: RuiLoureiro on June 10, 2014, 03:00:44 AM
        2 procedures to compare 2 "strings with spaces":

Hi Rui,
What would be a "real life" application of a sort routine that ignores spaces between words?

RuiLoureiro

Quote from: jj2007 on June 10, 2014, 04:04:15 AM
Quote from: RuiLoureiro on June 10, 2014, 03:00:44 AM
        2 procedures to compare 2 "strings with spaces":

Hi Rui,
What would be a "real life" application of a sort routine that ignores spaces between words?
for students and it is just "real life" also ! :biggrin:
                 but not only Jochen ! If the input procedure clean spaces ...
                 For instance, the date field. We need to test if it is correct
                 and we remove spaces in that time: "2088- 02- 30" just
                 your birth day ! :P 
                 Sorry if iam wrong  :biggrin: