using BenchmarkDotNet.Attributes;
using SoulstormReplayReader.Core;

namespace SoulstormReplayReader.Benchmarks;

// [SimpleJob(RuntimeMoniker.Net80)]
[MemoryDiagnoser]
public class Benchy
{
    private const string ReplaysDir = "./Replays/";

    public SsReplayReader SsReplayReader { get; set; }

    [Params(
        "1v1.rec"
        ,
        "4p_withbots.rec"
        ,
        "2v2v2.rec"
        ,
        "4v4.rec"
    )]
    public string Replay;

    [Params(
        false
        ,
        true
    )]
    public bool SkipImages;

    [GlobalSetup]
    public void Setup()
    {
        var memoryStream = new MemoryStream(File.ReadAllBytes(ReplaysDir + Replay), false);

        SsReplayReader = new SsReplayReader(memoryStream) { SkipImages = SkipImages };
    }

    // [Benchmark]
    // public void ReadHeader()
    // {
    //     SsReplayReader.ReadHeader();
    // }
    //
    // [Benchmark]
    // public void ReadInfo()
    // {
    //     SsReplayReader.ReadInfo();
    // }

    [Benchmark]
    public void ReadFull()
    {
        SsReplayReader.ReadFull();
    }

    [Benchmark]
    public void ReadFullWithoutOrdinaryTicks()
    {
        SsReplayReader.ReadFull(false);
    }

    [GlobalCleanup]
    public void Cleanup()
    {
        SsReplayReader.Dispose();
    }
}