Created
November 30, 2011 21:14
-
-
Save ThatRendle/1410853 to your computer and use it in GitHub Desktop.
Comparison of Simple.Data Bulk Insert with SQL Server Provider 0.12.1 and 0.12.2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
00:00:16.9799819 | |
00:00:17.1971797 | |
00:00:18.0744958 | |
00:00:19.1514537 | |
00:00:17.3798541 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
00:00:00.4616911 (First run includes the time to discover the IBulkInserter export in SqlServer assembly) | |
00:00:00.2757802 | |
00:00:00.2852119 | |
00:00:00.2504587 | |
00:00:00.2453277 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace BulkInsertComparison | |
{ | |
using System; | |
using System.Collections.Generic; | |
using System.Diagnostics; | |
using Simple.Data; | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var db = Database.OpenConnection("data source=.;initial catalog=BulkInsertTest;integrated security=true"); | |
for (int i = 0; i < 5; i++) | |
{ | |
Console.WriteLine(TimeInsert(db)); | |
} | |
} | |
private static TimeSpan TimeInsert(dynamic db) | |
{ | |
var stopwatch = Stopwatch.StartNew(); | |
db.Target.Insert(GenerateItems(10000)); | |
stopwatch.Stop(); | |
return stopwatch.Elapsed; | |
} | |
static IEnumerable<Item> GenerateItems(int number) | |
{ | |
for (int i = 0; i < number; i++) | |
{ | |
var guid = Guid.NewGuid(); | |
yield return new Item(0, guid, guid.ToString("N")); | |
} | |
} | |
} | |
class Item | |
{ | |
private readonly int _id; | |
private readonly Guid _guid; | |
private readonly string _text; | |
public Item(int id, Guid guid, string text) | |
{ | |
_id = id; | |
_guid = guid; | |
_text = text; | |
} | |
public string Text { get { return _text; } } | |
public Guid Guid { get { return _guid; } } | |
public int Id { get { return _id; } } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment