generated from Nexus-Mods/NexusMods.App.Template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #74 from Nexus-Mods/better-caching
Better caching
- Loading branch information
Showing
46 changed files
with
573 additions
and
241 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
benchmarks/NexusMods.MnemonicDB.Benchmarks/Benchmarks/ReadThenWriteBenchmarks.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using BenchmarkDotNet.Attributes; | ||
using NexusMods.Hashing.xxHash64; | ||
using NexusMods.MnemonicDB.Abstractions; | ||
using NexusMods.MnemonicDB.TestModel; | ||
using NexusMods.Paths; | ||
|
||
namespace NexusMods.MnemonicDB.Benchmarks.Benchmarks; | ||
|
||
[MemoryDiagnoser] | ||
[MaxIterationCount(20)] | ||
public class ReadThenWriteBenchmarks : ABenchmark | ||
{ | ||
|
||
private EntityId _modId; | ||
|
||
[GlobalSetup] | ||
public async Task Setup() | ||
{ | ||
await InitializeAsync(); | ||
|
||
using var tx = Connection.BeginTransaction(); | ||
|
||
var loadout = new Loadout.New(tx) | ||
{ | ||
Name = "My Loadout" | ||
}; | ||
|
||
for (int i = 0; i < 90; i++) | ||
{ | ||
var mod = new Mod.New(tx) | ||
{ | ||
Name = $"Mod {i}", | ||
Source = new System.Uri($"http://mod{i}.com"), | ||
LoadoutId = loadout, | ||
OptionalHash = Hash.FromLong(0) | ||
}; | ||
|
||
_modId = mod.Id; | ||
|
||
for (int j = 0; j < 1000; j++) | ||
{ | ||
var file = new File.New(tx) | ||
{ | ||
Path = $"File {j}", | ||
ModId = mod, | ||
Size = Size.FromLong(j), | ||
Hash = Hash.FromLong(j) | ||
}; | ||
} | ||
} | ||
|
||
var result = await tx.Commit(); | ||
_modId = result[_modId]; | ||
} | ||
|
||
[Benchmark] | ||
public async Task<ulong> ReadThenWrite() | ||
{ | ||
using var tx = Connection.BeginTransaction(); | ||
var mod = Mod.Load(Connection.Db, _modId); | ||
var oldHash = mod.OptionalHash; | ||
tx.Add(_modId, Mod.OptionalHash, Hash.From(oldHash.Value + 1)); | ||
var nextdb = await tx.Commit(); | ||
|
||
var loadout = Loadout.Load(Connection.Db, mod.LoadoutId); | ||
|
||
|
||
ulong totalSize = 0; | ||
foreach (var mod2 in loadout.Mods) | ||
{ | ||
foreach (var file in mod2.Files) | ||
{ | ||
totalSize += file.Size.Value; | ||
} | ||
} | ||
return totalSize; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 0 additions & 23 deletions
23
src/NexusMods.MnemonicDB.Storage/NexusMods.MnemonicDB.Storage.csproj
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.