Skip to content

Commit

Permalink
Move SqliteProfiler to core
Browse files Browse the repository at this point in the history
  • Loading branch information
jesuslpm committed Apr 28, 2014
1 parent e55d239 commit 91d6108
Show file tree
Hide file tree
Showing 69 changed files with 285 additions and 574 deletions.
12 changes: 3 additions & 9 deletions EntityLite.sln
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
# Visual Studio 2013
VisualStudioVersion = 12.0.21005.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "inercya.EntityLite", "inercya.EntityLite\inercya.EntityLite.csproj", "{B74DF500-8654-40D1-A50C-7262A2095B1E}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Items", "Items", "{A632C4A4-E33E-4C29-A084-CA91A0C0E494}"
Expand Down Expand Up @@ -52,8 +54,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CodeProject", "CodeProject"
CodeProject\EntityLite.htm = CodeProject\EntityLite.htm
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "inercya.EntityLite.SqliteProfiler", "SqliteLogger\inercya.EntityLite.SqliteProfiler.csproj", "{E585F6D5-06B3-421E-9600-281A04FF88D1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -78,12 +78,6 @@ Global
{263706E0-73DF-4987-8FE4-07DACAB63CCE}.Release|Any CPU.Build.0 = Release|Any CPU
{263706E0-73DF-4987-8FE4-07DACAB63CCE}.Release|x86.ActiveCfg = Release|x86
{263706E0-73DF-4987-8FE4-07DACAB63CCE}.Release|x86.Build.0 = Release|x86
{E585F6D5-06B3-421E-9600-281A04FF88D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E585F6D5-06B3-421E-9600-281A04FF88D1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E585F6D5-06B3-421E-9600-281A04FF88D1}.Debug|x86.ActiveCfg = Debug|Any CPU
{E585F6D5-06B3-421E-9600-281A04FF88D1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E585F6D5-06B3-421E-9600-281A04FF88D1}.Release|Any CPU.Build.0 = Release|Any CPU
{E585F6D5-06B3-421E-9600-281A04FF88D1}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Binary file modified EntityLite.v12.suo
Binary file not shown.
2 changes: 1 addition & 1 deletion Samples/EntityLite.ttinclude/EntityLite.ttinclude
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<#@ assembly name="Microsoft.CSharp" #>
<#@ assembly name="System.Data" #>
<#@ assembly name="System.Xml" #>
<#@ assembly name="$(SolutionDir)packages\EntityLite.Core.1.2.0\lib\net35-client\inercya.EntityLite.dll" #>
<#@ assembly name="$(SolutionDir)packages\EntityLite.Core.1.4.0\lib\net35-client\inercya.EntityLite.dll" #>
<#@ import namespace="System" #>
<#@ import namespace="System.Reflection" #>
<#@ import namespace="System.Data" #>
Expand Down
Binary file modified Samples/Northwind.mdf
Binary file not shown.
Binary file modified Samples/Northwind_log.ldf
Binary file not shown.
209 changes: 101 additions & 108 deletions Samples/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ limitations under the License.
using System.Configuration;
using System.Diagnostics;
using inercya.EntityLite.SqliteProfiler;
using inercya.EntityLite.Collections;

namespace Samples
{
Expand All @@ -40,119 +41,38 @@ class Program

static void Main(string[] args)
{
for (int i =0; i < 100; i++) TestQueue();
//profiler = new inercya.EntityLite.SqliteProfiler.Profiler();
//ProfilerLite.Current = profiler;
//profiler.StartProfiling();
//using (ds = new NorthwindDataService())
//{
// QueryByPrimaryKey();
// ShowSomeProducts();
// ShowOrderDetails();
// ShowQuesoCabralesOrders();
// ShowPagedProducts();
// ShowLondonAndewFullerSubtree();
// SearchOrderDetails();
// ShowProductSales();
// RaiseProductPrices();
// InsertUpdateDeleteProduct();
// RaiseProductPrices2();
// HandCraftedSql();
// Localization();

// Pivot();
//}
//profiler.StopProfiling();
//Console.WriteLine("Press enter to exit ...");
//Console.ReadLine();

}

static volatile bool isRunning = true;

static void TestQueue()
{

Thread[] threads = new Thread[8];
var queue = new SafeQueue<int>();
var signal = new AutoResetEvent(false);

HashSet<int> integers = new HashSet<int>();

isRunning = true;

Thread queueReader = new Thread(new ThreadStart ( delegate
//for (int i =0; i < 100; i++) TestQueue();
profiler = new inercya.EntityLite.SqliteProfiler.Profiler(
AppDomain.CurrentDomain.BaseDirectory,
ProfileFileFrecuency.Daily
);
ProfilerLite.Current = profiler;
profiler.StartProfiling();
using (ds = new NorthwindDataService())
{
while (true)
{
signal.WaitOne();
int n;
int count = 0;
while (queue.Dequeue(out n))
{
integers.Add(n);
count++;
}
//Console.WriteLine(count);
if (!isRunning) return;
}
}));

queueReader.Start();

Action<int> enqueue = (s) =>
{
for (int x = 0; x < 100000; x++)
{
queue.Enqueue(s + x);
signal.Set();
if (x % 100 == 0) Thread.Yield();
}
};

int start = 0;
for (int i = 0; i < 8; i++)
{

threads[i] = new Thread(new ParameterizedThreadStart((state) => enqueue((int)state)));
threads[i].Start(start);
start += 100000;
}

for (int i = 0; i < 8; i++)
{
threads[i].Join();
}
Thread.Yield();
isRunning = false;
signal.Set();

queueReader.Join();

bool failed = false;
for (int i = 0; i < 800000; i++)
{
if (!integers.Contains(i))
{
//Console.WriteLine("{0} failed", i);
failed = true;
}
QueryByPrimaryKey();
ShowSomeProducts();
ShowOrderDetails();
ShowQuesoCabralesOrders();
ShowPagedProducts();
ShowLondonAndewFullerSubtree();
SearchOrderDetails();
ShowProductSales();
RaiseProductPrices();
InsertUpdateDeleteProduct();
RaiseProductPrices2();
HandCraftedSql();
Localization();

Pivot();
}
if (failed) Console.WriteLine("Test failed");
//else Console.WriteLine("Test passed");
//Console.ReadLine();
}

private static NorthwindDataService CreateDataService()
{
var ds = new NorthwindDataService();

inercya.EntityLite.ProfilerLite.Current = new inercya.EntityLite.SqliteProfiler.Profiler();
return ds;
profiler.StopProfiling();
Console.WriteLine("Press enter to exit ...");
Console.ReadLine();

}



private static void Pivot()
{

Expand Down Expand Up @@ -545,5 +465,78 @@ static void InsertUpdateDeleteProduct()
ds.Commit();
}
}

static volatile bool isRunning = true;

static void TestQueue()
{

Thread[] threads = new Thread[8];
var queue = new SafeQueue<int>();
var signal = new AutoResetEvent(false);

HashSet<int> integers = new HashSet<int>();

isRunning = true;

Thread queueReader = new Thread(new ThreadStart(delegate
{
while (true)
{
signal.WaitOne();
int n;
int count = 0;
while (queue.Dequeue(out n))
{
integers.Add(n);
count++;
}
//Console.WriteLine(count);
if (!isRunning) return;
}
}));

queueReader.Start();

Action<int> enqueue = (s) =>
{
for (int x = 0; x < 100000; x++)
{
queue.Enqueue(s + x);
signal.Set();
if (x % 100 == 0) Thread.Yield();
}
};

int start = 0;
for (int i = 0; i < 8; i++)
{

threads[i] = new Thread(new ParameterizedThreadStart((state) => enqueue((int)state)));
threads[i].Start(start);
start += 100000;
}

for (int i = 0; i < 8; i++)
{
threads[i].Join();
}
Thread.Yield();
isRunning = false;
signal.Set();

queueReader.Join();

bool failed = false;
for (int i = 0; i < 800000; i++)
{
if (!integers.Contains(i))
{
//Console.WriteLine("{0} failed", i);
failed = true;
}
}
if (failed) Console.WriteLine("Test failed");
}
}
}
4 changes: 0 additions & 4 deletions Samples/Samples.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,6 @@
<Project>{b74df500-8654-40d1-a50c-7262a2095b1e}</Project>
<Name>inercya.EntityLite</Name>
</ProjectReference>
<ProjectReference Include="..\SqliteLogger\inercya.EntityLite.SqliteProfiler.csproj">
<Project>{e585f6d5-06b3-421e-9600-281a04ff88d1}</Project>
<Name>inercya.EntityLite.SqliteProfiler</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions Samples/packages.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="EntityLite" version="1.2.0" targetFramework="net40" />
<package id="EntityLite.Core" version="1.2.0" targetFramework="net40" />
<package id="EntityLite" version="1.4.0" targetFramework="net40" />
<package id="EntityLite.Core" version="1.4.0" targetFramework="net40" />
<package id="Microsoft.SqlServer.Types" version="10.50.1600.1" targetFramework="net40" />
<package id="MySql.Data" version="6.7.4" targetFramework="net40" />
<package id="NLog" version="2.1.0" targetFramework="net40" />
Expand Down
11 changes: 0 additions & 11 deletions SqliteLogger/Class1.cs

This file was deleted.

Loading

0 comments on commit 91d6108

Please sign in to comment.