mirror of
https://github.com/Biarity/Sieve.git
synced 2025-07-27 20:53:41 +02:00
Check for duplicate filteers/sorts and performance measurement code for SieveTests
This commit is contained in:
@@ -6,7 +6,7 @@ namespace SieveTests.Services
|
||||
{
|
||||
public class SieveCustomFilterMethods : ISieveCustomFilterMethods
|
||||
{
|
||||
public IQueryable<Post> IsNew(IQueryable<Post> source)
|
||||
public IQueryable<Post> IsNew(IQueryable<Post> source, string op, string value)
|
||||
=> source.Where(p => p.LikeCount < 100 && p.CommentCount < 5);
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,10 @@
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
@@ -37,6 +42,20 @@ namespace SieveTests
|
||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
|
||||
{
|
||||
// TIME MEASUREMENT
|
||||
var times = new List<long>();
|
||||
app.Use(async (context, next) =>
|
||||
{
|
||||
var sw = new Stopwatch();
|
||||
sw.Start();
|
||||
await next.Invoke();
|
||||
sw.Stop();
|
||||
times.Add(sw.ElapsedMilliseconds);
|
||||
var text = $"AVG: {(int)times.Average()}ms; AT {sw.ElapsedMilliseconds}; COUNT: {times.Count()}";
|
||||
Console.WriteLine(text);
|
||||
await context.Response.WriteAsync($"<!-- {text} -->");
|
||||
});
|
||||
|
||||
if (env.IsDevelopment())
|
||||
{
|
||||
app.UseDeveloperExceptionPage();
|
||||
|
15
SieveTests/pyprofile.py
Normal file
15
SieveTests/pyprofile.py
Normal file
@@ -0,0 +1,15 @@
|
||||
import urllib.request
|
||||
import time
|
||||
|
||||
for run in range(500):
|
||||
contents = urllib.request.urlopen("http://localhost:6500/api/posts/getall").read()
|
||||
print(contents[-50:])
|
||||
|
||||
|
||||
#for run in range(50):
|
||||
# contents = urllib.request.urlopen("http://localhost:6500/api/posts/getallWithSieve?filters=IsNew&sorts=popularity").read()
|
||||
# print(contents[-50:])
|
||||
# time.sleep(1)
|
||||
|
||||
print("done baseline")
|
||||
input()
|
Reference in New Issue
Block a user