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
4 changed files
with
86 additions
and
2 deletions.
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
46 changes: 46 additions & 0 deletions
46
tests/InfinityCrawler.Tests.Benchmarks/BasicSiteCrawlBenchmark.cs
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,46 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using BenchmarkDotNet.Attributes; | ||
using InfinityCrawler.TaskHandlers; | ||
using InfinityCrawler.Tests.TestSite; | ||
|
||
namespace InfinityCrawler.Tests.Benchmarks | ||
{ | ||
[CoreJob, ClrJob(baseline: true)] | ||
[MemoryDiagnoser] | ||
public class BasicSiteCrawlBenchmark | ||
{ | ||
private TestSiteManager TestSite { get; } | ||
private Crawler Crawler { get; } | ||
private Uri Uri { get; } = new Uri("http://localhost/"); | ||
|
||
public BasicSiteCrawlBenchmark() | ||
{ | ||
TestSite = new TestSiteManager(new SiteContext | ||
{ | ||
SiteFolder = "BasicSite" | ||
}); | ||
|
||
var client = TestSite.GetHttpClient(); | ||
Crawler = new Crawler(client, new ParallelAsyncTaskHandler()); | ||
} | ||
|
||
[Benchmark] | ||
public async Task CrawlSite() | ||
{ | ||
var result = await Crawler.Crawl(Uri, new CrawlSettings | ||
{ | ||
TaskHandlerOptions = new TaskHandlerOptions | ||
{ | ||
MaxNumberOfSimultaneousTasks = 5, | ||
DelayBetweenTaskStart = new TimeSpan(), | ||
DelayJitter = new TimeSpan(), | ||
TimeoutBeforeThrottle = new TimeSpan() | ||
} | ||
}); | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
tests/InfinityCrawler.Tests.Benchmarks/InfinityCrawler.Tests.Benchmarks.csproj
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,18 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFrameworks>netcoreapp2.1;net461</TargetFrameworks> | ||
<IsPackable>false</IsPackable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="BenchmarkDotNet" Version="0.11.3" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\InfinityCrawler\InfinityCrawler.csproj" /> | ||
<ProjectReference Include="..\InfinityCrawler.Tests.TestSite\InfinityCrawler.Tests.TestSite.csproj" /> | ||
</ItemGroup> | ||
|
||
</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,13 @@ | ||
using System; | ||
using BenchmarkDotNet.Running; | ||
|
||
namespace InfinityCrawler.Tests.Benchmarks | ||
{ | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
BenchmarkRunner.Run<BasicSiteCrawlBenchmark>(); | ||
} | ||
} | ||
} |