Skip to content

Instantly share code, notes, and snippets.

@stefansedich
Created November 21, 2011 21:17
Show Gist options
  • Select an option

  • Save stefansedich/1383969 to your computer and use it in GitHub Desktop.

Select an option

Save stefansedich/1383969 to your computer and use it in GitHub Desktop.
class Program
{
static void Main(string[] args)
{
var store = new DocumentStore { Url = "http://localhost:8080" }.Initialize();
try
{
var sw = Stopwatch.StartNew();
Parallel.ForEach(Enumerable.Range(0, 10000), i =>
{
var session = store.OpenSession();
session.Store(new Person { Name = Guid.NewGuid().ToString() });
session.SaveChanges();
});
sw.Stop();
Console.WriteLine("RavenDB Took: {0}", sw.Elapsed.ToString());
}
catch (Exception ex)
{
Console.WriteLine("RavenDB Failed: {0}", ex);
}
try
{
var sw = Stopwatch.StartNew();
Parallel.ForEach(Enumerable.Range(0, 10000), i =>
{
var connection = new SqlConnection(@"Data Source=localhost\SQLEXPRESS;Initial Catalog=Test;Integrated Security=SSPI;");
connection.Open();
connection.Execute("INSERT INTO PEOPLE (Name) VALUES (@Name)", new { Name = Guid.NewGuid().ToString() });
connection.Close();
});
sw.Stop();
Console.WriteLine("SQL Took: {0}", sw.Elapsed.ToString());
}
catch (Exception ex)
{
Console.WriteLine("SQL Failed {0}", ex);
}
Console.ReadKey();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment