move random gen to Math, working on VL4
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
// -----------------------------------------------------------------------
|
||||
// file="HlsfAllocatorBench"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. All rights reserved.
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -26,7 +26,7 @@
|
||||
// -----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
using BenchmarkDotNet.Attributes;
|
||||
using StgSharp.HighPerformance.Memory;
|
||||
using StgSharp.Mathematics.Memory;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace StgSharp.Benchmark
|
||||
@@ -40,15 +40,7 @@ namespace StgSharp.Benchmark
|
||||
|
||||
private const int AllocationCount = 2048;
|
||||
|
||||
private static readonly int[] AllocSizes = [
|
||||
64,
|
||||
96,
|
||||
150,
|
||||
200,
|
||||
400,
|
||||
1024,
|
||||
4096
|
||||
];
|
||||
private static readonly int[] AllocSizes = [64, 96, 150, 200, 400, 1024, 4096];
|
||||
private HybridLayerSegregatedFitAllocator _hlsfAllocator = null!;
|
||||
private readonly List<HybridLayerSegregatedFitAllocationHandle> _hlsfLocalList = new();
|
||||
private readonly List<nint> _libcLocalList = new();
|
||||
@@ -104,9 +96,7 @@ namespace StgSharp.Benchmark
|
||||
_hlsfAllocator = new HybridLayerSegregatedFitAllocator(GetArenaBytes(), align:(int)Alignment);
|
||||
}
|
||||
|
||||
private static uint AlignSize(
|
||||
uint size
|
||||
)
|
||||
private static uint AlignSize(uint size)
|
||||
{
|
||||
uint mask = Alignment - 1;
|
||||
return (size + mask) & ~mask;
|
||||
@@ -119,9 +109,7 @@ namespace StgSharp.Benchmark
|
||||
int mb = defaultMb;
|
||||
|
||||
string? env = Environment.GetEnvironmentVariable("HLSF_BENCH_ARENA_MB");
|
||||
if (!string.IsNullOrWhiteSpace(env) &&
|
||||
int.TryParse(env, out int parsed) &&
|
||||
parsed >= minMb) {
|
||||
if (!string.IsNullOrWhiteSpace(env) && int.TryParse(env, out int parsed) && parsed >= minMb) {
|
||||
mb = parsed;
|
||||
}
|
||||
|
||||
@@ -130,10 +118,7 @@ namespace StgSharp.Benchmark
|
||||
|
||||
private uint GetNextRandomSize() => (uint)AllocSizes[_random.Next(AllocSizes.Length)];
|
||||
|
||||
private void RunHlsf(
|
||||
HybridLayerSegregatedFitAllocator allocator,
|
||||
FreePolicy policy
|
||||
)
|
||||
private void RunHlsf(HybridLayerSegregatedFitAllocator allocator, FreePolicy policy)
|
||||
{
|
||||
_hlsfLocalList.Clear();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user