Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
melanchall committed Mar 13, 2020
2 parents 798cb40 + 6f8fea8 commit 33de149
Show file tree
Hide file tree
Showing 299 changed files with 13,949 additions and 2,360 deletions.
12 changes: 12 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# These are supported funding model platforms

github: # Replace with GitHub username(s)
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: ["paypal.me/melanchall"]
113 changes: 50 additions & 63 deletions Docs/latest-release-notes.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions DryWetMidi.Benchmarks/BenchmarkTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ protected void RunBenchmarks(Type type, params IColumn[] columns)
type,
ManualConfig.Create(DefaultConfig.Instance)
.With(AsciiDocExporter.Default, JsonExporter.Brief)
.With(StatisticColumn.Min)
.With(columns));

// Assert validation errors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Engines;
using Melanchall.DryWetMidi.Core;
using Melanchall.DryWetMidi.Tests.Common;
using NUnit.Framework;

namespace Melanchall.DryWetMidi.Benchmarks.Smf
namespace Melanchall.DryWetMidi.Benchmarks.Core
{
[TestFixture]
public class MidiFileReadBenchmarks : BenchmarkTest
Expand All @@ -23,12 +24,6 @@ public enum MidiFileSize

#endregion

#region Constants

private const string FilesPath = @"..\..\..\..\Resources\MIDI files\Valid";

#endregion

#region Nested classes

public abstract class Benchmarks
Expand All @@ -40,76 +35,84 @@ public abstract class Benchmarks
[Benchmark]
public void Read()
{
MidiFileReadBenchmarks.Read(FileFormat, FileSize);
MidiFileReadBenchmarks.Read(FileFormat, FileSize, new ReadingSettings());
}

[Benchmark]
public void Read_ReadFromMemory()
{
var settings = new ReadingSettings();
settings.ReaderSettings.ReadFromMemory = true;
MidiFileReadBenchmarks.Read(FileFormat, FileSize, settings);
}
}

[InProcessSimpleJob(RunStrategy.Throughput)]
public class Benchmarks_SingleTrack_Small : Benchmarks
public class Benchmarks_ReadFile_SingleTrack_Small : Benchmarks
{
public override MidiFileFormat FileFormat => MidiFileFormat.SingleTrack;

public override MidiFileSize FileSize => MidiFileSize.Small;
}

[InProcessSimpleJob(RunStrategy.Monitoring, warmupCount: 5, targetCount: 5, launchCount: 5, invocationCount: 5)]
public class Benchmarks_SingleTrack_Middle : Benchmarks
public class Benchmarks_ReadFile_SingleTrack_Middle : Benchmarks
{
public override MidiFileFormat FileFormat => MidiFileFormat.SingleTrack;

public override MidiFileSize FileSize => MidiFileSize.Middle;
}

[InProcessSimpleJob(RunStrategy.Monitoring, warmupCount: 5, targetCount: 5, launchCount: 5, invocationCount: 5)]
public class Benchmarks_SingleTrack_Large : Benchmarks
public class Benchmarks_ReadFile_SingleTrack_Large : Benchmarks
{
public override MidiFileFormat FileFormat => MidiFileFormat.SingleTrack;

public override MidiFileSize FileSize => MidiFileSize.Large;
}

[InProcessSimpleJob(RunStrategy.Throughput)]
public class Benchmarks_MultiTrack_Small : Benchmarks
public class Benchmarks_ReadFile_MultiTrack_Small : Benchmarks
{
public override MidiFileFormat FileFormat => MidiFileFormat.MultiTrack;

public override MidiFileSize FileSize => MidiFileSize.Small;
}

[InProcessSimpleJob(RunStrategy.Monitoring, warmupCount: 5, targetCount: 5, launchCount: 5, invocationCount: 5)]
public class Benchmarks_MultiTrack_Middle : Benchmarks
public class Benchmarks_ReadFile_MultiTrack_Middle : Benchmarks
{
public override MidiFileFormat FileFormat => MidiFileFormat.MultiTrack;

public override MidiFileSize FileSize => MidiFileSize.Middle;
}

[InProcessSimpleJob(RunStrategy.Monitoring, warmupCount: 5, targetCount: 5, launchCount: 5, invocationCount: 5)]
public class Benchmarks_MultiTrack_Large : Benchmarks
public class Benchmarks_ReadFile_MultiTrack_Large : Benchmarks
{
public override MidiFileFormat FileFormat => MidiFileFormat.MultiTrack;

public override MidiFileSize FileSize => MidiFileSize.Large;
}

[InProcessSimpleJob(RunStrategy.Throughput)]
public class Benchmarks_MultiSequence_Small : Benchmarks
public class Benchmarks_ReadFile_MultiSequence_Small : Benchmarks
{
public override MidiFileFormat FileFormat => MidiFileFormat.MultiSequence;

public override MidiFileSize FileSize => MidiFileSize.Small;
}

[InProcessSimpleJob(RunStrategy.Monitoring, warmupCount: 5, targetCount: 5, launchCount: 5, invocationCount: 5)]
public class Benchmarks_MultiSequence_Middle : Benchmarks
public class Benchmarks_ReadFile_MultiSequence_Middle : Benchmarks
{
public override MidiFileFormat FileFormat => MidiFileFormat.MultiSequence;

public override MidiFileSize FileSize => MidiFileSize.Middle;
}

[InProcessSimpleJob(RunStrategy.Monitoring, warmupCount: 5, targetCount: 5, launchCount: 5, invocationCount: 5)]
public class Benchmarks_MultiSequence_Large : Benchmarks
public class Benchmarks_ReadFile_MultiSequence_Large : Benchmarks
{
public override MidiFileFormat FileFormat => MidiFileFormat.MultiSequence;

Expand All @@ -120,34 +123,34 @@ public class Benchmarks_MultiSequence_Large : Benchmarks

#region Test methods

[TestCase(typeof(Benchmarks_SingleTrack_Small))]
[TestCase(typeof(Benchmarks_SingleTrack_Middle))]
[TestCase(typeof(Benchmarks_SingleTrack_Large))]
[TestCase(typeof(Benchmarks_MultiTrack_Small))]
[TestCase(typeof(Benchmarks_MultiTrack_Middle))]
[TestCase(typeof(Benchmarks_MultiTrack_Large))]
[TestCase(typeof(Benchmarks_MultiSequence_Small))]
[TestCase(typeof(Benchmarks_MultiSequence_Middle))]
[TestCase(typeof(Benchmarks_MultiSequence_Large))]
public void Read(Type type)
[TestCase(typeof(Benchmarks_ReadFile_SingleTrack_Small))]
[TestCase(typeof(Benchmarks_ReadFile_SingleTrack_Middle))]
[TestCase(typeof(Benchmarks_ReadFile_SingleTrack_Large))]
[TestCase(typeof(Benchmarks_ReadFile_MultiTrack_Small))]
[TestCase(typeof(Benchmarks_ReadFile_MultiTrack_Middle))]
[TestCase(typeof(Benchmarks_ReadFile_MultiTrack_Large))]
[TestCase(typeof(Benchmarks_ReadFile_MultiSequence_Small))]
[TestCase(typeof(Benchmarks_ReadFile_MultiSequence_Middle))]
[TestCase(typeof(Benchmarks_ReadFile_MultiSequence_Large))]
public void ReadFile(Type type)
{
var instance = Activator.CreateInstance(type);
var fileFormat = (MidiFileFormat)type.GetProperty(nameof(Benchmarks.FileFormat)).GetValue(instance);
var fileSize = (MidiFileSize)type.GetProperty(nameof(Benchmarks.FileSize)).GetValue(instance);

var eventsCount = GetEventsCount(fileFormat, fileSize);
var eventsCount = GetEventsCount(fileFormat, fileSize, new ReadingSettings());
RunBenchmarks(type, new MidiFileEventsCountsColumn(eventsCount));
}

#endregion

#region Private methods

private int[] GetEventsCount(MidiFileFormat midiFileFormat, MidiFileSize midiFileSize)
private int[] GetEventsCount(MidiFileFormat midiFileFormat, MidiFileSize midiFileSize, ReadingSettings settings)
{
var result = new List<int>();

foreach (var midiFile in GetFiles(midiFileFormat, midiFileSize))
foreach (var midiFile in GetFiles(midiFileFormat, midiFileSize, settings))
{
var events = midiFile.GetTrackChunks().SelectMany(c => c.Events).ToList();
result.Add(events.Count);
Expand All @@ -156,16 +159,16 @@ private int[] GetEventsCount(MidiFileFormat midiFileFormat, MidiFileSize midiFil
return result.ToArray();
}

protected static void Read(MidiFileFormat midiFileFormat, MidiFileSize midiFileSize)
protected static void Read(MidiFileFormat midiFileFormat, MidiFileSize midiFileSize, ReadingSettings settings)
{
GetFiles(midiFileFormat, midiFileSize).ToList();
GetFiles(midiFileFormat, midiFileSize, settings).ToList();
}

private static IEnumerable<MidiFile> GetFiles(MidiFileFormat midiFileFormat, MidiFileSize midiFileSize)
private static IEnumerable<MidiFile> GetFiles(MidiFileFormat midiFileFormat, MidiFileSize midiFileSize, ReadingSettings settings)
{
foreach (var filePath in Directory.GetFiles(Path.Combine(FilesPath, midiFileFormat.ToString(), midiFileSize.ToString())))
foreach (var filePath in Directory.GetFiles(Path.Combine(TestFilesProvider.ValidFilesPath, midiFileFormat.ToString(), midiFileSize.ToString())))
{
yield return MidiFile.Read(filePath);
yield return MidiFile.Read(filePath, settings);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Engines;
using Melanchall.DryWetMidi.Core;
using Melanchall.DryWetMidi.Tests.Common;
using NUnit.Framework;

namespace Melanchall.DryWetMidi.Benchmarks.Core
{
[TestFixture]
public sealed class MidiFileReadingHandlerBenchmarks : BenchmarkTest
{
#region Nested classes

private sealed class EmptyHandler : ReadingHandler
{
public EmptyHandler()
: base(TargetScope.Event | TargetScope.File | TargetScope.TrackChunk)
{
}
}

[InProcessSimpleJob(RunStrategy.Monitoring, warmupCount: 5, targetCount: 5, launchCount: 5, invocationCount: 5)]
public class Benchmarks_ReadingHandler
{
[Benchmark]
public void Read_WithoutHandlers()
{
var midiFile = MidiFile.Read(TestFilesProvider.GetMiscFile_14000events());
}

[Benchmark]
public void Read_WithEmptyHandler()
{
var handler = new EmptyHandler();
var settings = new ReadingSettings();
settings.ReadingHandlers.Add(handler);

var midiFile = MidiFile.Read(TestFilesProvider.GetMiscFile_14000events(), settings);
}
}

#endregion

#region Test methods

[Test]
public void ReadMidiFileUsingHandler()
{
RunBenchmarks<Benchmarks_ReadingHandler>();
}

#endregion
}
}
Loading

0 comments on commit 33de149

Please sign in to comment.