StringBuilder Performance Test : StringBuilder « Language Basics « VB.Net

Home
VB.Net
1.2D
2.Application
3.Class
4.Data Structure
5.Data Types
6.Database ADO.net
7.Development
8.Event
9.File Directory
10.Generics
11.GUI
12.Language Basics
13.LINQ
14.Network Remote
15.Security
16.Thread
17.Windows Presentation Foundation
18.Windows System
19.XML
20.XML LINQ
VB.Net Tutorial
VB.Net by API
VB.Net » Language Basics » StringBuilderScreenshots 
StringBuilder Performance Test
 
Imports System

Public Class MainClass

  Shared Sub Main()
        Dim As Integer
        Dim StartTime As New DateTime()
        Dim EndTime As New DateTime()
        StartTime = DateTime.Now()
        Dim theText As New System.Text.StringBuilder()
        For i = To 50000
            theText = theText.Append("A")
        Next
        EndTime = DateTime.Now
        Dim answer1, answer2 As Long
        answer1 = EndTime.Ticks() - StartTime.Ticks()
        StartTime = DateTime.Now()
        Dim aString As String = ""
        For i = To 50000
            aString = aString & "A"
        Next
        EndTime = DateTime.Now
        answer2 = (EndTime.Ticks() - StartTime.Ticks()) 
        Console.WriteLine("StringBuilder was " & answer2 / answer1 & " times faster.")
  End Sub


End Class




           
         
  
Related examples in the same category
1.Use StringBuilder for fast processing stringsUse StringBuilder for fast processing strings
2.StringBuilder: Char and ReplaceStringBuilder: Char and Replace
3.Demonstrating StringBuilder class constructorsDemonstrating StringBuilder class constructors
4.StringBuilder Length and CapacityStringBuilder Length and Capacity
5.Use StringBuilder IndexerUse StringBuilder Indexer
6.StringBuilder Append methodsStringBuilder Append methods
7.StringBuilder method AppendFormatStringBuilder method AppendFormat
8.Insert and Remove of the StringBuilder classInsert and Remove of the StringBuilder class
9.StringBuilder Replace methodStringBuilder Replace method
10.Append String to StringBuilderAppend String to StringBuilder
11.Append bool data type values to a StringBuilder object.
12.Append SByte data type values to a StringBuilder object.
13.Insert String to StringBuilder
14.Insert char array to StringBuilder
15.Insert Object to StringBuilder
16.Insert xInt32 to StringBuilder
17.Insert System.SByte to StringBuilder
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.