Improve `BIZHAWKBUILD_RUN_ONLY_GAMEDB_INIT`

This commit is contained in:
YoshiRulz 2024-12-15 19:53:36 +10:00
parent 9e9687f026
commit 48f5125c84
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
3 changed files with 20 additions and 4 deletions

View File

@ -15,7 +15,7 @@
, profileManagedCalls
}: let
/**
* you can make use of the call duration data by seeing which methods it's spending the longest in: `mprof-report --reports=call --method-sort=self output/*.flame.mlpd` (really you'd want to sort by self/count but that's not an option)
* you can make use of the call duration data by seeing which methods it's spending the longest in: `mprof-report --reports=call --method-sort=self output/*.flame.mlpd` (really you'd want to sort by the ratio `self/count` but that's not an option)
*
* the other useful profiling mode is allocations: `nix-shell --argstr profileManagedCalls " --profile=log:alloc,nocalls,output=%t.alloc.mlpd"`
* you can make use of the allocation data by listing which types had the most instances allocated: `mprof-report --reports=alloc --alloc-sort=count output/*.alloc.mlpd`

View File

@ -222,7 +222,12 @@ namespace BizHawk.Emulation.Common
DB = _builder.ToFrozenDictionary();
_builder.Clear();
if (_expected.Count is not 0) Util.DebugWriteLine($"extra bundled gamedb files were not #included: {string.Join(", ", _expected)}");
Util.DebugWriteLine("GameDB load: " + stopwatch.Elapsed + " sec");
#if BIZHAWKBUILD_RUN_ONLY_GAMEDB_INIT
Console.WriteLine( // should be optimising for measurement so want to print then
#else
Util.DebugWriteLine( // ...but for most users it's just noise
#endif
$"GameDB load: {stopwatch.Elapsed} sec");
_acquire.Set();
});
}

View File

@ -1,3 +1,4 @@
using System.Diagnostics;
using System.IO;
using BizHawk.Common;
@ -25,8 +26,18 @@ namespace BizHawk.Emulation.Cores
{
RomStatus StatusFor(string hashDigest)
=> Database.CheckDatabase(hashDigest)?.Status ?? RomStatus.NotInDatabase;
Console.WriteLine(StatusFor(SHA1Checksum.EmptyFile)); // NotInDatabase
Console.WriteLine(StatusFor("3064E664D34859649B67559F0ED0C2FFD6948031")); // BadDump
Console.WriteLine($"ex: NotInDatabase, ac: {StatusFor(SHA1Checksum.EmptyFile)}");
Console.WriteLine($"ex: BadDump, ac: {StatusFor("3064E664D34859649B67559F0ED0C2FFD6948031")}");
Console.WriteLine($"ex: GoodDump, ac: {StatusFor("B558814D54904CE0582E2F6A801D03AF")}");
var giBanjo = Database.CheckDatabase("1FE1632098865F639E22C11B9A81EE8F29C75D7A");
Console.WriteLine($"ex: 4, ac: {(
giBanjo is null
? "(DB miss)"
: giBanjo.OptionValue("RiceRenderToTextureOption") ?? "(option not present)"
)}");
var stopwatch = Stopwatch.StartNew();
for (var i = 0; i < 1_000_000; i++) _ = StatusFor("3064E664D34859649B67559F0ED0C2FFD6948031");
Console.WriteLine($"lookup perf test: {stopwatch.Elapsed}");
}
}
}