启动时间测试

This commit is contained in:
橙子
2023-01-16 21:10:00 +08:00
parent 506686b11e
commit 46b176fc59
5 changed files with 36 additions and 8 deletions

View File

@@ -7,7 +7,12 @@
</PropertyGroup>
<ItemGroup>
<Folder Include="Module\" />
<Compile Remove="Module\**" />
<EmbeddedResource Remove="Module\**" />
<None Remove="Module\**" />
</ItemGroup>
<ItemGroup>
<Folder Include="Options\" />
</ItemGroup>

View File

@@ -26,7 +26,6 @@ namespace Yi.Framework.Core
public void ConfigureServices(IServiceCollection services, ConfigureServicesContext context)
{
//添加全局配置类
services.AddSingleton(new Appsettings(context.Configuration));
//全盘扫描,自动依赖注入

View File

@@ -1,7 +1,3 @@
using AspNetCore.Microsoft.AspNetCore.Builder;
using Autofac;
using System.Reflection;
using Yi.Framework.Application;
using Yi.Framework.Application.Contracts;
using Yi.Framework.Core;
@@ -16,7 +12,7 @@ using Yi.Framework.Domain.Shared;
using Yi.Framework.Sqlsugar;
using Yi.Framework.Web;
TimeTest.Start();
var builder = WebApplication.CreateBuilder(args);
builder.WebHost.UseUrls(builder.Configuration.GetValue<string>("StartUrl"));
@@ -50,4 +46,9 @@ var app = builder.Build();
var t = app.Services.GetService<Test2Entity>();
app.MapControllers();
app.Run();

View File

@@ -0,0 +1,23 @@
using System.Diagnostics;
namespace Yi.Framework.Web
{
public class TimeTest
{
public static Stopwatch Stopwatch { get; set; }
public static void Start()
{
Stopwatch=new Stopwatch();
Stopwatch.Start();
}
public static void Result()
{
Stopwatch.Stop();
string time = Stopwatch.ElapsedMilliseconds.ToString();
Console.WriteLine($"本次运行启动时间为:{time}毫秒");
Stopwatch.Restart();
}
}
}

View File

@@ -34,7 +34,7 @@ namespace Yi.Framework.Web
app.UseAuthorization();
app.UseRouting();
TimeTest.Result();
}
}