-
-
Notifications
You must be signed in to change notification settings - Fork 228
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
269 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" /> | ||
</startup> | ||
</configuration> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{DE991A5E-575C-4B0F-B93D-6D283E5928D6}</ProjectGuid> | ||
<OutputType>Exe</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>MemoryLeakTest</RootNamespace> | ||
<AssemblyName>MemoryLeakTest</AssemblyName> | ||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Linq.Dynamic, Version=1.0.6132.35681, Culture=neutral, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\System.Linq.Dynamic.1.0.7\lib\net40\System.Linq.Dynamic.dll</HintPath> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="System.Linq.Dynamic.Core, Version=0.0.0.0, Culture=neutral, PublicKeyToken=0f07ec44de6ac832, processorArchitecture=MSIL"> | ||
<HintPath>..\..\src\System.Linq.Dynamic.Core\bin\Release\net35\System.Linq.Dynamic.Core.dll</HintPath> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Person.cs" /> | ||
<Compile Include="Pet.cs" /> | ||
<Compile Include="Program.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
<Compile Include="Test.cs" /> | ||
<Compile Include="Toy.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="App.config" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System; | ||
|
||
namespace MemoryLeakTest | ||
{ | ||
public class Person | ||
{ | ||
public Guid Id; | ||
|
||
public string Name; | ||
|
||
public int From; | ||
|
||
public int Till; | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System; | ||
|
||
namespace MemoryLeakTest | ||
{ | ||
public class Pet | ||
{ | ||
public Guid Id; | ||
|
||
public string Name; | ||
|
||
public Person Owner; | ||
|
||
public Guid OwnerId { get { return Owner.Id; } } | ||
|
||
public int From; | ||
|
||
public int Till; | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System; | ||
|
||
namespace MemoryLeakTest | ||
{ | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
Console.WriteLine("press key to run"); | ||
Console.ReadKey(); | ||
|
||
Test t = new Test(); | ||
t.Join(); | ||
} | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("MemoryLeakTest")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("MemoryLeakTest")] | ||
[assembly: AssemblyCopyright("Copyright © 2017")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("de991a5e-575c-4b0f-b93d-6d283e5928d6")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// You can specify all the values or you can default the Build and Revision Numbers | ||
// by using the '*' as shown below: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Linq; | ||
using System.Linq.Dynamic.Core; | ||
|
||
namespace MemoryLeakTest | ||
{ | ||
public class Test | ||
{ | ||
public void Join() | ||
{ | ||
//Arrange | ||
Person magnus = new Person { Id = Guid.NewGuid(), Name = "Hedlund, Magnus", From = 100, Till = 1000 }; | ||
Person terry = new Person { Id = Guid.NewGuid(), Name = "Adams, Terry", From = 10230, Till = 100440 }; | ||
Person charlotte = new Person { Id = Guid.NewGuid(), Name = "Weiss, Charlotte", From = 10, Till = 154 }; | ||
|
||
Pet barley = new Pet { Id = Guid.NewGuid(), Name = "Barley", Owner = terry, From = 67, Till = 231 }; | ||
Pet boots = new Pet { Id = Guid.NewGuid(), Name = "Boots", Owner = terry, From = 120, Till = 220 }; | ||
Pet whiskers = new Pet { Id = Guid.NewGuid(), Name = "Whiskers", Owner = charlotte, From = 3310, Till = 9010 }; | ||
Pet daisy = new Pet { Id = Guid.NewGuid(), Name = "Daisy", Owner = magnus, From = 27, Till = 1200 }; | ||
|
||
Toy ball1 = new Toy { Id = Guid.NewGuid(), From = 10, Till = 200, Pet = barley }; | ||
Toy ball2 = new Toy { Id = Guid.NewGuid(), From = 89, Pet = barley, Till = 348 }; | ||
Toy duck1 = new Toy { Id = Guid.NewGuid(), From = 10, Till = 200, Pet = boots }; | ||
Toy duck2 = new Toy { Id = Guid.NewGuid(), From = 89, Pet = whiskers, Till = 348 }; | ||
Toy toy1 = new Toy { Id = Guid.NewGuid(), From = 10, Till = 200, Pet = boots }; | ||
Toy toy2 = new Toy { Id = Guid.NewGuid(), From = 89, Pet = daisy, Till = 348 }; | ||
Toy something1 = new Toy { Id = Guid.NewGuid(), From = 10, Till = 200, Pet = daisy }; | ||
Toy something2 = new Toy { Id = Guid.NewGuid(), From = 89, Pet = barley, Till = 348 }; | ||
Toy toy3 = new Toy { Id = Guid.NewGuid(), From = 10, Till = 200, Pet = daisy }; | ||
Toy toy4 = new Toy { Id = Guid.NewGuid(), From = 89, Pet = whiskers, Till = 348 }; | ||
|
||
|
||
IList people = new List<Person> { magnus, terry, charlotte }; | ||
IList pets = new List<Pet> { barley, boots, whiskers, daisy }; | ||
IList toys = new List<Toy> { ball1, ball2, duck1, duck2, toy1, toy2, something1, something2, toy3, toy4 }; | ||
|
||
//Act | ||
var sw = new Stopwatch(); | ||
long t = 0; | ||
var rnd = new Random(); | ||
for (var i = 0; i < 400; i++) | ||
{ | ||
sw.Start(); | ||
Act(people, pets, toys, rnd); | ||
sw.Stop(); | ||
t = sw.ElapsedMilliseconds; | ||
if (i % 10 == 0) | ||
{ | ||
Console.WriteLine("{0} - {1}", i, t); | ||
} | ||
sw.Reset(); | ||
} | ||
} | ||
|
||
private dynamic[] Act(IList people, IList pets, IList toys, Random rnd) | ||
{ | ||
var peopleQ = people.AsQueryable().Where(string.Format("From<{0} AND Till>{1}", rnd.Next(0, 500), rnd.Next(500, 20000))); | ||
var petsQ = pets.AsQueryable().Where(string.Format("From<{0} AND Till>{1}", rnd.Next(0, 500), rnd.Next(500, 20000))); | ||
var toyQ = toys.AsQueryable().Where(string.Format("From<{0} AND Till>{1}", rnd.Next(0, 500), rnd.Next(500, 20000))); | ||
|
||
var q1 = petsQ.Join(toyQ, "new (Id as firstKey)", "new (PetId as firstKey)", "new (inner as toy, outer as pet)"); | ||
var q2 = peopleQ.Join(q1, "new (Id as firstKey)", "new (pet.OwnerId as firstKey)", "new (inner as pet, outer as person)") | ||
.Select("new (person.Name as personName, pet.pet.Name as petName, pet.toy.Id as toyUid)"); | ||
|
||
var result = q2.ToDynamicArray(); | ||
return result; | ||
} | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System; | ||
|
||
namespace MemoryLeakTest | ||
{ | ||
public class Toy | ||
{ | ||
public Guid Id; | ||
|
||
public int From; | ||
|
||
public int Till; | ||
|
||
public Pet Pet; | ||
|
||
public Guid PetId { get { return Pet.Id; } } | ||
} | ||
} |