using System IO using System Linq using System Threading Tasks using B

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using Flurl.Http.Testing;
using Goblin.Narfu.Old;
using Goblin.Narfu.Old.Models;
namespace Goblin.Narfu.Benchmarks
{
internal class Program
{
private static void Main(string[] args)
{
var summary = BenchmarkRunner.Run<OldVsNew>();
}
}
[MemoryDiagnoser]
public class OldVsNew
{
private string data;
[GlobalSetup]
public void Setup()
{
data = File.ReadAllText(@"E:\equus\Downloads\RUZ 2020.02.17-2020.08.15 351617.ics");
}
[Benchmark]
public async Task<Lesson[]> OldParser()
{
var api = new NarfuApi();
using var test = new HttpTest();
test.RespondWith(data);
var lessons = await api.Students.GetSchedule(351617);
return lessons.ToArray();
}
[Benchmark]
public async Task<New.Models.Lesson[]> NewParser()
{
var api = new New.NarfuApi();
using var test = new HttpTest();
test.RespondWith(data);
var lessons = await api.Students.GetSchedule(351617);
return lessons.ToArray();
}
}
}