mirror of
https://github.com/SK-la/osu-framework.git
synced 2026-03-13 11:20:31 +00:00
35 lines
889 B
C#
35 lines
889 B
C#
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
using System;
|
|
using System.IO;
|
|
using BenchmarkDotNet.Attributes;
|
|
using osu.Framework.Extensions;
|
|
|
|
namespace osu.Framework.Benchmarks
|
|
{
|
|
[MemoryDiagnoser]
|
|
public class BenchmarkStreamExtensions
|
|
{
|
|
private MemoryStream memoryStream = null!;
|
|
|
|
[Params(100, 10000, 1000000)]
|
|
public int Length { get; set; }
|
|
|
|
[GlobalSetup]
|
|
public void GlobalSetup()
|
|
{
|
|
byte[] array = new byte[Length];
|
|
var random = new Random(42);
|
|
random.NextBytes(array);
|
|
memoryStream = new MemoryStream(array);
|
|
}
|
|
|
|
[Benchmark]
|
|
public byte[] ReadAllBytesToArray()
|
|
{
|
|
return memoryStream.ReadAllBytesToArray();
|
|
}
|
|
}
|
|
}
|