On 12/9/06 3:14 AM, Norman Palardy at [EMAIL PROTECTED]
wrote:

> Did you try ReplaceALLB so there's no consideration of encodings ?
> The perl code would not handle anything but ascii either

Good point, and I hadn¹t. With ReplaceAllB, the RB code still wins over
perl.

At this point, it looks like the bulk of the penalty was in IsNumeric.

The revised perl code:

perl -le 'my $isOdd=1 ; my $caseStr="case " ; my $varStr = "r = \"" ; my
$closingStr = "\"\n" ; while (<>) { chomp ; if ($isOdd) {print ($caseStr ,
$_) ; $isOdd=0} else {s|\"|\"\"|g ; print($varStr , $_ , $closingStr) ;
$isOdd=1} }' test.txt > perltest.txt


The revised RB code:

  #pragma BackgroundTasks false
  #pragma BoundsChecking false
  
  dim fIn, fOut as FolderItem
  dim t as Double = microseconds
  
  fIn = DesktopFolder.Child( "test.txt" )
  fOut = DesktopFolder.Child( "output.txt" )
  
  dim tIn as TextInputStream = fIn.OpenAsTextFile
  dim tOut as TextOutputStream = fOut.CreateTextFile
  
  dim caseStr as string = "case "
  dim varStr as string = "r = """
  dim closingStr as string = """" + chr( 13 )
  
  dim line as string
  dim isOdd as boolean = true
  do until tIn.EOF
    line =  tIn.ReadLine
    if isOdd then
      tOut.Write( caseStr )
      tOut.WriteLine( line )
      isOdd = false
    else
      line = line.ReplaceAllB( """", """""" )
      tOut.Write( varStr )
      tOut.Write( line )
      tOut.WriteLine( closingStr )
      isOdd = true
    end if
  loop
  
  tIn.Close
  tOut.Close
  
  t = microseconds - t
  t = t / 1000000
  
  MsgBox( format( t, "#,0.000" ) + " seconds" )
  

__________________________________________________________________________
Kem Tekinay                                                 (212) 201-1465
MacTechnologies Consulting                              Fax (914) 242-7294
http://www.mactechnologies.com                        Pager (917) 491-5546

  To join the MacTechnologies Consulting mailing list, send an e-mail to:
           [EMAIL PROTECTED]






_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to