Created
September 14, 2010 04:55
-
-
Save saintedlama/578567 to your computer and use it in GitHub Desktop.
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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using SubSonic.DataProviders; | |
using SubSonic.Repository; | |
using SubSonic.Tests.Repositories; | |
using SubSonic.Tests.Repositories.TestBases; | |
using Xunit; | |
namespace SubSonic.Tests.Perf | |
{ | |
public class Projections | |
{ | |
[Fact] | |
public void Measure_ProjectionSpeedSetup() | |
{ | |
var provider = ProviderFactory.GetProvider("Northwind"); | |
provider.Log = Console.Out; | |
var repo = new SimpleRepository(provider, SimpleRepositoryOptions.RunMigrations); | |
// Create some test items | |
for (var i = 0; i < 1000; i++) | |
{ | |
var movie = new Movie { Title = "SomeTitle" }; | |
repo.Add(movie); | |
for (var j = 0; j < 10; j++) | |
{ | |
var comment = new Comment { Author = "Me", MovieId = movie.Id, Text = "The film is... " }; | |
repo.Add(comment); | |
} | |
} | |
} | |
[Fact] | |
public void Measure_ProjectionSpeed() | |
{ | |
var provider = ProviderFactory.GetProvider("Northwind"); | |
provider.Log = Console.Out; | |
var repo = new SimpleRepository(provider, SimpleRepositoryOptions.RunMigrations); | |
var t1 = DateTime.Now; | |
var result = (from m in repo.All<Movie>() | |
from c in repo.All<Comment>() | |
where m.Id == c.MovieId | |
select new ProjectionResult { Title = m.Title, Comment = c.Text }).ToString(); | |
var t2 = DateTime.Now; | |
Console.Out.WriteLine("Time elapsed for selecting and mapping " + (t2 - t1).TotalMilliseconds + " ms"); | |
} | |
} | |
public class ProjectionResult | |
{ | |
public string Title { get; set; } | |
public string Comment { get; set; } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment