Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions benchmarks/HydraScript.Benchmarks/GeneratedRegexContainer.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Domain\HydraScript.Domain.Constants\HydraScript.Domain.Constants.csproj"
OutputItemType="Analyzer" SetTargetFramework="TargetFramework=netstandard2.0"/>
<ProjectReference Include="..\..\src\Infrastructure\HydraScript.Infrastructure.LexerRegexGenerator\HydraScript.Infrastructure.LexerRegexGenerator.csproj"
OutputItemType="Analyzer"
ReferenceOutputAssembly="false"
SetTargetFramework="TargetFramework=netstandard2.0"/>
<ProjectReference Include="..\..\src\Infrastructure\HydraScript.Infrastructure\HydraScript.Infrastructure.csproj"/>
</ItemGroup>

Expand Down
15 changes: 11 additions & 4 deletions benchmarks/HydraScript.Benchmarks/InvokeBenchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,40 @@ public class InvokeBenchmark
{
private ServiceProvider? _provider;
private Executor? _executor;
private readonly UpdatableFileOptions _updatableFileOptions = new(new FileInfo(nameof(FileInfo)));

private readonly IReadOnlyList<FileInfo> _scriptPaths =
private readonly UpdatableFileOptions _updatableFileOptions = new(new FileInfo(nameof(FileInfo)));
private readonly FileInfo[] _scriptPaths =
Directory.GetFiles("Samples")
.Select(x => new FileInfo(x))
.ToArray();

private readonly int _benchmarkSize;

public InvokeBenchmark() => _benchmarkSize = _scriptPaths.Length / 3;

[GlobalSetup]
public void GlobalSetup()
{
_provider = new ServiceCollection()
.AddLogging(x => x.ClearProviders().AddProvider(NullLoggerProvider.Instance))
.AddDomain<GeneratedRegexContainer>()
.AddDomain()
.AddApplication()
.AddInfrastructure(dump: false, _updatableFileOptions.Value)
.AddSingleton<IOptions<FileInfo>>(_updatableFileOptions)
.BuildServiceProvider();
_executor = _provider.GetRequiredService<Executor>();
}

[IterationSetup]
public void IterationSetup() => Random.Shared.Shuffle(_scriptPaths);

[GlobalCleanup]
public void GlobalCleanup() => _provider?.Dispose();

[Benchmark]
public void Invoke()
{
for (var i = 0; i < _scriptPaths.Count; i++)
for (var i = 0; i <_benchmarkSize; i++)
{
_updatableFileOptions.Update(_scriptPaths[i]);
_executor?.Invoke();
Expand Down
4 changes: 0 additions & 4 deletions src/HydraScript/HydraScript.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Infrastructure\HydraScript.Infrastructure.LexerRegexGenerator\HydraScript.Infrastructure.LexerRegexGenerator.csproj"
OutputItemType="Analyzer"
ReferenceOutputAssembly="false"
PrivateAssets="all" />
<ProjectReference Include="..\Infrastructure\HydraScript.Infrastructure\HydraScript.Infrastructure.csproj" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/HydraScript/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ private static ExecuteCommand GetCommand()
private static ServiceProvider GetServiceProvider(FileInfo fileInfo, bool dump) =>
new ServiceCollection()
.AddLogging(c => c.ClearProviders().AddZLoggerConsole())
.AddDomain<GeneratedRegexContainer>()
.AddDomain()
.AddApplication()
.AddInfrastructure(dump, fileInfo)
.BuildServiceProvider();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" PrivateAssets="all"/>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Domain\HydraScript.Domain.Constants\HydraScript.Domain.Constants.csproj" PrivateAssets="all" OutputItemType="Analyzer" />
<Compile Include="..\..\Domain\HydraScript.Domain.Constants\*.cs" LinkBase="_Constants"/>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
using System.Text.RegularExpressions;
using HydraScript.Domain.FrontEnd.Lexer;
using HydraScript.Infrastructure;

namespace HydraScript;
namespace HydraScript.Infrastructure;

public sealed partial class GeneratedRegexContainer : IGeneratedRegexContainer
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<ItemGroup>
<ProjectReference Include="..\HydraScript.Infrastructure.LexerRegexGenerator\HydraScript.Infrastructure.LexerRegexGenerator.csproj"
OutputItemType="Analyzer"
ReferenceOutputAssembly="false"
PrivateAssets="all" />
<ProjectReference Include="..\..\Application\HydraScript.Application.CodeGeneration\HydraScript.Application.CodeGeneration.csproj" />
<ProjectReference Include="..\..\Application\HydraScript.Application.StaticAnalysis\HydraScript.Application.StaticAnalysis.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@ namespace HydraScript.Infrastructure;

public static class ServiceCollectionExtensions
{
public static IServiceCollection AddDomain<TGeneratedRegexContainer>(this IServiceCollection services)
where TGeneratedRegexContainer : class, IGeneratedRegexContainer
public static IServiceCollection AddDomain(this IServiceCollection services)
{
services.AddSingleton<ITextCoordinateSystemComputer, TextCoordinateSystemComputer>();
services.AddSingleton<ITokenTypesProvider, TokenTypesProvider>();
services.AddSingleton<IStructure, Structure<TGeneratedRegexContainer>>();
services.AddSingleton<IStructure, Structure<GeneratedRegexContainer>>();
services.AddSingleton<ILexer, RegexLexer>();
services.AddSingleton<IParser, TopDownParser>();

Expand Down
2 changes: 1 addition & 1 deletion tests/HydraScript.IntegrationTests/TestHostFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void Dispose()
public Runner GetRunner(Options options, Action<IServiceCollection>? configureTestServices = null)
{
var services = new ServiceCollection()
.AddDomain<GeneratedRegexContainer>()
.AddDomain()
.AddApplication()
.AddInfrastructure(options.Dump, new FileInfo(options.FileName));
const string serilogTemplate = "[{Timestamp:HH:mm:ss} {Level:u} [{SourceContext}]]{NewLine}{Message:lj} {Exception}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using HydraScript.Domain.FrontEnd.Lexer;
using HydraScript.Domain.FrontEnd.Lexer.Impl;
using HydraScript.Domain.FrontEnd.Lexer.TokenTypes;
using HydraScript.Infrastructure;

namespace HydraScript.UnitTests.Domain.FrontEnd;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using HydraScript.Domain.FrontEnd.Lexer;
using HydraScript.Domain.FrontEnd.Lexer.Impl;
using HydraScript.Domain.FrontEnd.Lexer.TokenTypes;
using HydraScript.Infrastructure;

namespace HydraScript.UnitTests.Domain.FrontEnd;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using HydraScript.Domain.FrontEnd.Lexer.Impl;
using HydraScript.Domain.FrontEnd.Parser;
using HydraScript.Domain.FrontEnd.Parser.Impl;
using HydraScript.Infrastructure;

namespace HydraScript.UnitTests.Domain.FrontEnd;

Expand Down
Loading