EgorBot / runtime-utils

MIT License
0 stars 1 forks source link

tes #69

Open EgorBo opened 2 months ago

EgorBo commented 2 months ago

@EgorBot -alltargets

using System.Text.Json;
using BenchmarkDotNet.Attributes;

public class Perf_Basic
{
    [Benchmark]
    public Employee? JsonRoundtrip()
    {
        Employee manager = new Employee("John", "Manager", 30, 185.5, new DateTime(1990, 10, 10), null);
        Employee employee = new Employee("John", "Manager", 30, 185.5, new DateTime(1990, 10, 10), manager);
        var str = JsonSerializer.Serialize(employee);
        return JsonSerializer.Deserialize<Employee>(str);
    }
}

public record Employee(string name, string title, int age, double height, DateTime applyDate, Employee? manager);
EgorBo commented 2 months ago

@EgorBot -alltargets

using System.Text.Json;
using BenchmarkDotNet.Attributes;

public class Perf_Basic
{
    static readonly Employee[] Data = Enumerable.Range(1, 4096)
        .Select(i => new Employee("John", "Manager", 30, 185.5, new DateTime(1990, 10, 10),
            new Employee("Джон", "Разработчик", 30 + i, 185.5, new DateTime(1990, 10, 10), null))).ToArray();

    [Benchmark]
    public Employee[]? JsonRoundtrip()
    {
        var str = JsonSerializer.Serialize(Data);
        return JsonSerializer.Deserialize<Employee[]>(str);
    }
}

public record Employee(string name, string title, int age, double height, DateTime applyDate, Employee? manager);
EgorBo commented 2 months ago

@EgorBot -intel -amd

using System.Text.Json;
using BenchmarkDotNet.Attributes;

public class Perf_Basic
{
    static readonly Employee[] Data = Enumerable.Range(1, 4096)
        .Select(i => new Employee("John", "Manager", 30, 185.5, new DateTime(1990, 10, 10),
            new Employee("Джон", "Разработчик", 30 + i, 185.5, new DateTime(1990, 10, 10), null))).ToArray();

    [Benchmark]
    public Employee[]? JsonRoundtrip()
    {
        var str = JsonSerializer.Serialize(Data);
        return JsonSerializer.Deserialize<Employee[]>(str);
    }
}

public record Employee(string name, string title, int age, double height, DateTime applyDate, Employee? manager);