mirror of https://github.com/ivanch/tcc.git
Compare commits
3 Commits
2390f8fb8d
...
09c7345e68
Author | SHA1 | Date |
---|---|---|
José Henrique Ivanchechen | 09c7345e68 | |
José Henrique Ivanchechen | 258f3a0243 | |
José Henrique Ivanchechen | 6f6a77f897 |
|
@ -3,7 +3,7 @@
|
||||||
namespace TCC.Controllers
|
namespace TCC.Controllers
|
||||||
{
|
{
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Route("")]
|
[Route("status")]
|
||||||
public class StatusController : ControllerBase
|
public class StatusController : ControllerBase
|
||||||
{
|
{
|
||||||
public StatusController() { }
|
public StatusController() { }
|
|
@ -0,0 +1,20 @@
|
||||||
|
FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine AS build-env
|
||||||
|
WORKDIR /App
|
||||||
|
|
||||||
|
# Copy everything
|
||||||
|
COPY * .
|
||||||
|
|
||||||
|
# Restore as distinct layers
|
||||||
|
RUN dotnet restore
|
||||||
|
|
||||||
|
# Build a release
|
||||||
|
RUN dotnet build -c Release -o out
|
||||||
|
|
||||||
|
# Build runtime image
|
||||||
|
FROM mcr.microsoft.com/dotnet/aspnet:6.0-alpine
|
||||||
|
|
||||||
|
WORKDIR /App
|
||||||
|
|
||||||
|
COPY --from=build-env /App/out .
|
||||||
|
|
||||||
|
ENTRYPOINT ["dotnet", "/App/TCC.APP.dll"]
|
|
@ -1,4 +1,3 @@
|
||||||
using Microsoft.AspNetCore.Http.Features;
|
|
||||||
using Microsoft.AspNetCore.Server.Kestrel.Core;
|
using Microsoft.AspNetCore.Server.Kestrel.Core;
|
||||||
using TCC.Services;
|
using TCC.Services;
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
"dotnetRunMessages": true,
|
"dotnetRunMessages": true,
|
||||||
"launchBrowser": false,
|
"launchBrowser": false,
|
||||||
"launchUrl": "weatherforecast",
|
"launchUrl": "weatherforecast",
|
||||||
"applicationUrl": "http://localhost:5100",
|
"applicationUrl": "http://0.0.0.0:5100",
|
||||||
"environmentVariables": {
|
"environmentVariables": {
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
}
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Trace",
|
||||||
|
"Microsoft.AspNetCore": "Trace"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"AllowedHosts": "*"
|
||||||
|
}
|
|
@ -1,9 +0,0 @@
|
||||||
{
|
|
||||||
"Logging": {
|
|
||||||
"LogLevel": {
|
|
||||||
"Default": "Information",
|
|
||||||
"Microsoft.AspNetCore": "Warning"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"AllowedHosts": "*"
|
|
||||||
}
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
import requests
|
||||||
|
import concurrent.futures
|
||||||
|
import time
|
||||||
|
|
||||||
|
URL_BASE = 'http://localhost:5100'
|
||||||
|
|
||||||
|
num_requests = [1000, 5000, 10_000, 50_000, 100_000, 500_000, 1_000_000]
|
||||||
|
|
||||||
|
def send_request(session, url):
|
||||||
|
response = session.get(url)
|
||||||
|
return response.status_code
|
||||||
|
|
||||||
|
def main():
|
||||||
|
for num_request in num_requests:
|
||||||
|
with concurrent.futures.ThreadPoolExecutor(max_workers=10) as executor:
|
||||||
|
url = f'{URL_BASE}/status/ok'
|
||||||
|
|
||||||
|
start_time = time.time()
|
||||||
|
|
||||||
|
futures = []
|
||||||
|
with requests.Session() as session:
|
||||||
|
futures = [executor.submit(send_request, session, url) for _ in range(num_request)]
|
||||||
|
|
||||||
|
concurrent.futures.wait(futures)
|
||||||
|
|
||||||
|
elapsed_time = time.time() - start_time
|
||||||
|
|
||||||
|
successful_responses = sum(1 for future in futures if future.result() == 200)
|
||||||
|
|
||||||
|
print(f"All requests completed in {elapsed_time:.2f} seconds. {elapsed_time/num_request:.4f} seconds per request. {num_request/elapsed_time:.2f} requests per second.")
|
||||||
|
print(f"Successful responses: {successful_responses}/{num_request}")
|
||||||
|
|
||||||
|
main()
|
Loading…
Reference in New Issue