Home > CSV Benchmarks

   Base   
 
INTRODUCTION:

           For the people that can only trust raw numbers, or for the people who just might want to simply see the performance benefits of using CsvReader over what they've been using, simple benchmarks are provided below to attempt to give a rough picture of the comparisons. These results should be very reproducible. A very simple test file format was used just to test raw file processing power and to exclude differences in functionality across the different packages. Keep in mind that each package has its own features and syntax, and all that's being compared here is raw processing speed under a specific situation.

TEST FILE CREATION:

           VB.NET:
		Dim writer As New CsvWriter("C:\verylarge.csv")

		Dim random As New Random

		For j As Integer = 0 To 19

			For i As Integer = 0 To 65535

				writer.Write(random.Next().ToString(), True)
				writer.Write(random.Next().ToString(), True)
				writer.Write(random.Next().ToString(), True)
				writer.Write(random.Next().ToString(), True)
				writer.Write(random.Next().ToString(), True)
				writer.EndRecord()

			Next

		Next

		writer.Close()

		writer.Dispose()
           C#:
		using (CsvWriter writer = new CsvWriter(@"C:\verylarge.csv"))
		{
			Random random = new Random();

			for (int j = 0; j < 20; j++)
			{
				for (int i = 0; i < 65536; i++)
				{
					writer.Write(random.Next().ToString(), true);
					writer.Write(random.Next().ToString(), true);
					writer.Write(random.Next().ToString(), true);
					writer.Write(random.Next().ToString(), true);
					writer.Write(random.Next().ToString(), true);
					writer.EndRecord();
				}
			}
		}
TEST FILE FORMAT:

           930086460,84532493,1388180560,1221957350,806121496
           1264133231,1643331990,1681813010,1337239887,408125903
           123472240,490484808,1530589550,1089858148,1702568686
           ...

TEST FILE SIZE:

           68.37 MB

QUESTIONS / COMMENTS:

           For questions or comments, email bruce@csvreader.com

   Our CsvReader   
 
TEST RESULTS:

           3.41 seconds

TEST CODE:

           VB.NET:
		Dim reader As New CsvReader("C:\verylarge.csv")

		While reader.ReadRecord()

			Dim test1 As String = reader.Item(0)
			Dim test2 As String = reader.Item(1)
			Dim test3 As String = reader.Item(2)
			Dim test4 As String = reader.Item(3)
			Dim test5 As String = reader.Item(4)

		End While

		reader.Close()

		reader.Dispose()
           C#:
		using (CsvReader reader = new CsvReader(@"C:\verylarge.csv"))
		{
			while (reader.ReadRecord())
			{
				string test1 = reader[0];
				string test2 = reader[1];
				string test3 = reader[2];
				string test4 = reader[3];
				string test5 = reader[4];
			}
		}

   ODBC Microsoft Text Driver   
 
TEST RESULTS:

           27.83 seconds

TEST CODE:

           VB.NET:
		Dim path As String = "C:\"

		Dim conn As New OdbcConnection( _
			"Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=" & _
			path & ";Extensions=asc,csv,tab,txt")

		Dim cmd As New OdbcCommand("SELECT * FROM verylarge.csv", conn)

		conn.Open()

		Dim dr As OdbcDataReader = _
			cmd.ExecuteReader(CommandBehavior.SequentialAccess)

		While dr.Read()

			Dim test1 As Integer = dr.GetInt32(0)
			Dim test2 As Integer = dr.GetInt32(1)
			Dim test3 As Integer = dr.GetInt32(2)
			Dim test4 As Integer = dr.GetInt32(3)
			Dim test5 As Integer = dr.GetInt32(4)

		End While

		dr.Close()

		cmd.Dispose()

		conn.Dispose()
           C#:
		string path = @"C:\";

		using (OdbcConnection conn = new OdbcConnection(
			"Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=" +
			path + ";Extensions=asc,csv,tab,txt"))
		{
			using (OdbcCommand cmd = 
				new OdbcCommand("SELECT * FROM verylarge.csv", conn))
			{
				conn.Open();

				using (OdbcDataReader dr =
					cmd.ExecuteReader(CommandBehavior.SequentialAccess))
				{
					while (dr.Read())
					{
						int test1 = dr.GetInt32(0);
						int test2 = dr.GetInt32(1);
						int test3 = dr.GetInt32(2);
						int test4 = dr.GetInt32(3);
						int test5 = dr.GetInt32(4);
					}
				}
			}
		}

   Microsoft Jet OLE Driver   
 
TEST RESULTS:

           12.88 seconds

TEST CODE:

           VB.NET:
		Dim path As String = "C:\"

		Dim conn As New OleDbConnection( _
			"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & path & _
			";Extended Properties=""Text;HDR=No;FMT=Delimited""")

		Dim cmd As New OleDbCommand("SELECT * FROM verylarge.csv", conn)

		conn.Open()

		Dim dr As OleDbDataReader = _
			cmd.ExecuteReader(CommandBehavior.SequentialAccess)

		While dr.Read()

			Dim test1 As Integer = dr.GetInt32(0)
			Dim test2 As Integer = dr.GetInt32(1)
			Dim test3 As Integer = dr.GetInt32(2)
			Dim test4 As Integer = dr.GetInt32(3)
			Dim test5 As Integer = dr.GetInt32(4)

		End While

		dr.Close()

		cmd.Dispose()

		conn.Dispose()
           C#:
		string path = @"C:\";

		using (OleDbConnection conn =
			new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +
			path + @";Extended Properties=""Text;HDR=No;FMT=Delimited"""))
		{
			using (OleDbCommand cmd = 
				new OleDbCommand("SELECT * FROM verylarge.csv", conn))
			{
				conn.Open();

				using (OleDbDataReader dr = 
					cmd.ExecuteReader(CommandBehavior.SequentialAccess))
				{
					while (dr.Read())
					{
						int test1 = dr.GetInt32(0);
						int test2 = dr.GetInt32(1);
						int test3 = dr.GetInt32(2);
						int test4 = dr.GetInt32(3);
						int test5 = dr.GetInt32(4);
					}
				}
			}
		}