Tutorials to .com

Tutorials to .com » Asp » Optimization » On the "&" operator inefficiencies have any good solution?

On the "&" operator inefficiencies have any good solution?

Print View , by: iSee ,Total views: 4 ,Word Count: 269 ,Date: Fri, 17 Apr 2009 Time: 7:34 PM

Let us take a look.

We know that the "&" than its "+" sign soon. Because the "+" characters to determine the type of channeling variables and do the conversion.

What was thought a good way. Only two "&" open computing speed to double. Or solve the problem.
The result is: for i 1 to 5000, i to form the sum of characters. Use the & operator, to 600-800ms

Now try the following. Build a class CStrCat.

PageExeTime1 = Timer * 1000 'time to start

Set sc = new CStrCat
For i = 0 To 5000
sc.add i
response.write sc.value

'Timing the end of
Response.Write ", Processed time:" & fix (abs (CDBL (Timer) * 1000 - PageExeTime1)) & "ms </ font> </ p>"

Class CStrCat 'This is the beginning category.
Private i, sa ()
Public Property Get Value
redim preserve sa (i)
Value = Join (sa, "")
End Property
Private Sub Class_Initialize ()
i = clng (0)
redim sa (500)
End Sub
Private Sub class_terminate ()
erase sa
End Sub
Public function Add (ps)
if len (ps) = 0 Then Exit function
if (i> = ubound (sa)) Then upsize
sa (i) = ps
i = i +1
End function
Private Sub upsize ()
Dim u
u = ubound (sa)
redim preserve sa (clng (u + u * 0.1))
End Sub
End Class

Asp Optimization Articles

Can't Find What You're Looking For?

Rating: Not yet rated


No comments posted.