mirror of
https://github.com/SK-la/osu-framework.git
synced 2026-03-15 03:20:30 +00:00
56 lines
1.3 KiB
C#
56 lines
1.3 KiB
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 BenchmarkDotNet.Attributes;
|
|
using osu.Framework.Logging;
|
|
using osu.Framework.Testing;
|
|
|
|
namespace osu.Framework.Benchmarks
|
|
{
|
|
[MemoryDiagnoser]
|
|
public class BenchmarkLogger
|
|
{
|
|
private const int line_count = 10000;
|
|
|
|
[GlobalSetup]
|
|
public void GlobalSetup()
|
|
{
|
|
Logger.Storage = new TemporaryNativeStorage(Guid.NewGuid().ToString());
|
|
}
|
|
|
|
[Benchmark]
|
|
public void LogManyLinesDebug()
|
|
{
|
|
for (int i = 0; i < line_count; i++)
|
|
{
|
|
Logger.Log("This is a test log line.", level: LogLevel.Debug);
|
|
}
|
|
|
|
Logger.Flush();
|
|
}
|
|
|
|
[Benchmark]
|
|
public void LogManyMultiLineLines()
|
|
{
|
|
for (int i = 0; i < line_count; i++)
|
|
{
|
|
Logger.Log("This\nis\na\ntest\nlog\nline.");
|
|
}
|
|
|
|
Logger.Flush();
|
|
}
|
|
|
|
[Benchmark]
|
|
public void LogManyLines()
|
|
{
|
|
for (int i = 0; i < line_count; i++)
|
|
{
|
|
Logger.Log("This is a test log line.");
|
|
}
|
|
|
|
Logger.Flush();
|
|
}
|
|
}
|
|
}
|