Skip to content

Instantly share code, notes, and snippets.

@lefthandedgoat
Created December 27, 2013 00:41
Show Gist options
  • Save lefthandedgoat/8140847 to your computer and use it in GitHub Desktop.
Save lefthandedgoat/8140847 to your computer and use it in GitHub Desktop.
gemini speed test
using System;
using System.Collections.Generic;
using System.Linq;
using Massive;
using Oak;
namespace ConsoleApplication1
{
public class DynamicPerson : DynamicModel
{
public DynamicPerson(object dto)
: base(dto)
{
}
}
public class Persons : DynamicRepository
{
public Persons()
: base("Person")
{
Projection = d => new DynamicPerson(d);
}
}
class Program
{
static void Main(string[] args)
{
//CreateTable();
//Insert100kRows();
PrimeTheDbForSelectStatement();
var peoples = new Persons();
var sw = new System.Diagnostics.Stopwatch();
sw.Start();
var oakPeople = peoples.All().ToList();
foreach (var person in oakPeople)
{
if ((person.Id as int?) == 0) { }
}
sw.Stop();
var time = sw.ElapsedMilliseconds;
Console.WriteLine("Finished in {0}ms", time);
//Console.ReadKey();
}
public static void CreateTable()
{
var seed = new Seed();
seed.PurgeDb();
seed.CreateTable("Person", new dynamic[]
{
seed.Id(),
new { FirstName = "nvarchar(255)" },
new { MiddleName = "nvarchar(255)" },
new { LastName = "nvarchar(255)" },
new { DateOfBirth = "datetime" },
new { Created = "datetime" },
new { Updated = "datetime" },
new { Deleted = "datetime" },
new { IsCool = "bit" },
new { FavoriteColor = "int" },
}).ExecuteNonQuery();
}
public static void Insert100kRows()
{
var peoples = new Persons();
var lotsOfPeople = new List<dynamic>();
for (int i = 0; i < 100000; i++)
{
lotsOfPeople.Add(new
{
FirstName = Guid.NewGuid().ToString(),
MiddleName = Guid.NewGuid().ToString(),
LastName = Guid.NewGuid().ToString(),
DateOfBirth = DateTime.Now,
Created = DateTime.Now,
Updated = DateTime.Now,
Deleted = DateTime.Now,
IsCool = false,
FavoriteColor = 4,
});
}
peoples.Save(lotsOfPeople.ToArray());
}
public static void PrimeTheDbForSelectStatement()
{
var reader = "select * from Person".ExecuteReader();
reader.Close();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment