From b29f360c026cd551858cf7af93f55b5d5a55d7a7 Mon Sep 17 00:00:00 2001 From: Pepper0ni <93387759+Pepper0ni@users.noreply.github.com> Date: Wed, 18 Sep 2024 12:52:20 +0100 Subject: [PATCH 1/8] messy first implementation, pushing for verification --- .../Enhancements/randomizer/3drando/fill.cpp | 31 ++++++++++++++ .../Enhancements/randomizer/3drando/menu.cpp | 40 +++++++++++++++++++ .../randomizer/3drando/playthrough.cpp | 4 ++ soh/soh/Enhancements/randomizer/context.h | 24 +++++++++++ soh/soh/Enhancements/randomizer/logic.cpp | 9 +++++ 5 files changed, 108 insertions(+) diff --git a/soh/soh/Enhancements/randomizer/3drando/fill.cpp b/soh/soh/Enhancements/randomizer/3drando/fill.cpp index 366fa1ed1ae..c7995445e33 100644 --- a/soh/soh/Enhancements/randomizer/3drando/fill.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/fill.cpp @@ -1149,6 +1149,7 @@ int Fill() { //Temporarily add shop items to the ItemPool so that entrance randomization //can validate the world using deku/hylian shields + std::chrono::_V2::system_clock::time_point metricStart = std::chrono::high_resolution_clock::now(); AddElementsToPool(ItemPool, GetMinVanillaShopItems(32)); //assume worst case shopsanity 4 if (ctx->GetOption(RSK_SHUFFLE_ENTRANCES)) { SPDLOG_INFO("Shuffling Entrances..."); @@ -1159,7 +1160,11 @@ int Fill() { } SPDLOG_INFO("Shuffling Entrances Done"); } + std::chrono::_V2::system_clock::time_point entranceToAreaTime = std::chrono::high_resolution_clock::now(); + ctx->entranceShuffleDuration += (entranceToAreaTime - metricStart); SetAreas(); + std::chrono::_V2::system_clock::time_point areaToShopTime = std::chrono::high_resolution_clock::now(); + ctx->setAreasDuration += (areaToShopTime - entranceToAreaTime); //erase temporary shop items FilterAndEraseFromPool(ItemPool, [](const auto item) { return Rando::StaticData::RetrieveItem(item).GetItemType() == ITEMTYPE_SHOP; }); @@ -1211,6 +1216,8 @@ int Fill() { //Place the shop items which will still be at shop locations AssumedFill(shopItems, shopLocations); } + std::chrono::_V2::system_clock::time_point shopToDungeonsTime = std::chrono::high_resolution_clock::now(); + ctx->shopDuration += (shopToDungeonsTime - areaToShopTime); //Place dungeon rewards SPDLOG_INFO("Shuffling and Placing Dungeon Items..."); @@ -1221,6 +1228,9 @@ int Fill() { RandomizeOwnDungeon(dungeon); } + std::chrono::_V2::system_clock::time_point dungeonsToLimitedTime = std::chrono::high_resolution_clock::now(); + ctx->dungeonsDuration += (dungeonsToLimitedTime - shopToDungeonsTime); + //Then Place songs if song shuffle is set to specific locations if (ctx->GetOption(RSK_SHUFFLE_SONGS).IsNot(RO_SONG_SHUFFLE_ANYWHERE)) { @@ -1249,16 +1259,25 @@ int Fill() { //Then place Link's Pocket Item if it has to be an advancement item RandomizeLinksPocket(); + + std::chrono::_V2::system_clock::time_point limitedToAdvancmentTime = std::chrono::high_resolution_clock::now(); + ctx->limitedDuration += (limitedToAdvancmentTime - dungeonsToLimitedTime); + SPDLOG_INFO("Shuffling Advancement Items"); //Then place the rest of the advancement items std::vector remainingAdvancementItems = FilterAndEraseFromPool(ItemPool, [](const auto i) { return Rando::StaticData::RetrieveItem(i).IsAdvancement(); }); AssumedFill(remainingAdvancementItems, ctx->allLocations, true); + std::chrono::_V2::system_clock::time_point advancmentToRemainingTime = std::chrono::high_resolution_clock::now(); + ctx->advancmentDuration += (advancmentToRemainingTime - limitedToAdvancmentTime); + //Fast fill for the rest of the pool SPDLOG_INFO("Shuffling Remaining Items"); std::vector remainingPool = FilterAndEraseFromPool(ItemPool, [](const auto i) { return true; }); FastFill(remainingPool, GetAllEmptyLocations(), false); + + ctx->remainingDuration += (std::chrono::high_resolution_clock::now() - advancmentToRemainingTime); //Add default prices to scrubs for (size_t i = 0; i < Rando::StaticData::scrubLocations.size(); i++) { @@ -1284,19 +1303,31 @@ int Fill() { } } + metricStart = std::chrono::high_resolution_clock::now(); GeneratePlaythrough(); + std::chrono::_V2::system_clock::time_point playthroughEnd = std::chrono::high_resolution_clock::now(); + ctx->playthroughDuration += (playthroughEnd - metricStart); //Successful placement, produced beatable result if(ctx->playthroughBeatable && !placementFailure) { SPDLOG_INFO("Calculating Playthrough..."); PareDownPlaythrough(); + std::chrono::_V2::system_clock::time_point pareDownToWoth = std::chrono::high_resolution_clock::now(); + ctx->pareDownDuration += (pareDownToWoth - playthroughEnd); CalculateWotH(); + std::chrono::_V2::system_clock::time_point WothToFoolish = std::chrono::high_resolution_clock::now(); + ctx->WotHDuration += (WothToFoolish - pareDownToWoth); CalculateBarren(); SPDLOG_INFO("Calculating Playthrough Done"); + std::chrono::_V2::system_clock::time_point foolishToOverrides = std::chrono::high_resolution_clock::now(); + ctx->FoolishDuration += (foolishToOverrides - WothToFoolish); ctx->CreateItemOverrides(); ctx->GetEntranceShuffler()->CreateEntranceOverrides(); + std::chrono::_V2::system_clock::time_point overridesToHints = std::chrono::high_resolution_clock::now(); + ctx->OverridesDuration += (overridesToHints - foolishToOverrides); CreateAllHints(); CreateWarpSongTexts(); + ctx->HintsDuration += (std::chrono::high_resolution_clock::now() - overridesToHints); return 1; } //Unsuccessful placement diff --git a/soh/soh/Enhancements/randomizer/3drando/menu.cpp b/soh/soh/Enhancements/randomizer/3drando/menu.cpp index 76cf6f1bc90..dc58506f368 100644 --- a/soh/soh/Enhancements/randomizer/3drando/menu.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/menu.cpp @@ -24,6 +24,20 @@ Rando::Option* currentSetting; bool GenerateRandomizer(std::set excludedLocations, std::set enabledTricks, std::string seedInput) { const auto ctx = Rando::Context::GetInstance(); + ctx->metricStart = std::chrono::high_resolution_clock::now(); + ctx->updateHelpersDuration = std::chrono::milliseconds(0); + ctx->entranceShuffleDuration = std::chrono::milliseconds(0); + ctx->shopDuration = std::chrono::milliseconds(0); + ctx->dungeonsDuration = std::chrono::milliseconds(0); + ctx->limitedDuration = std::chrono::milliseconds(0); + ctx->advancmentDuration = std::chrono::milliseconds(0); + ctx->remainingDuration = std::chrono::milliseconds(0); + ctx->playthroughDuration = std::chrono::milliseconds(0); + ctx->pareDownDuration = std::chrono::milliseconds(0); + ctx->WotHDuration = std::chrono::milliseconds(0); + ctx->FoolishDuration = std::chrono::milliseconds(0); + ctx->OverridesDuration = std::chrono::milliseconds(0); + ctx->HintsDuration = std::chrono::milliseconds(0); srand(time(NULL)); // if a blank seed was entered, make a random one @@ -65,5 +79,31 @@ bool GenerateRandomizer(std::set excludedLocations, std::setGetOption(RSK_KEYSANITY).RestoreDelayedOption(); } + + std::chrono::duration duration = std::chrono::high_resolution_clock::now() - ctx->metricStart; + SPDLOG_DEBUG("Full Seed Genration Time: {}ms", duration.count()); + duration = ctx->SCLResetEnd - ctx->SCLResetStart; + SPDLOG_DEBUG("SCL reset time: {}ms", duration.count()); + duration = ctx->LogicResetEnd - ctx->LogicResetStart; + SPDLOG_DEBUG("LogicReset time: {}ms", duration.count()); + duration = ctx->areaResetEnd - ctx->areaResetStart; + SPDLOG_DEBUG("Area->Reset time: {}ms", duration.count()); + duration = ctx->logEnd - ctx->logStart; + SPDLOG_DEBUG("SpoilerLog writing time: {}ms", duration.count()); + SPDLOG_DEBUG("Total UpdateHelpers time: {}ms", ctx->updateHelpersDuration.count()); + SPDLOG_DEBUG("Total Entrance Shuffle time: {}ms", ctx->entranceShuffleDuration.count()); + SPDLOG_DEBUG("Total SetAreas time: {}ms", ctx->setAreasDuration.count()); + SPDLOG_DEBUG("Total Shopsanity time: {}ms", ctx->shopDuration.count()); + SPDLOG_DEBUG("Total Dungeon Specific Items time: {}ms", ctx->dungeonsDuration.count()); + SPDLOG_DEBUG("Total Misc Limited Checks time: {}ms", ctx->limitedDuration.count()); + SPDLOG_DEBUG("Total Advancment Checks time: {}ms", ctx->advancmentDuration.count()); + SPDLOG_DEBUG("Total Other Checks time: {}ms", ctx->remainingDuration.count()); + SPDLOG_DEBUG("Total Playthrough Generation time: {}ms", ctx->playthroughDuration.count()); + SPDLOG_DEBUG("Total ParDownPlaythrough time: {}ms", ctx->pareDownDuration.count()); + SPDLOG_DEBUG("Total WotH generation time: {}ms", ctx->WotHDuration.count()); + SPDLOG_DEBUG("Total Foolish generation time: {}ms", ctx->FoolishDuration.count()); + SPDLOG_DEBUG("Total Overrides time: {}ms", ctx->OverridesDuration.count()); + SPDLOG_DEBUG("Total Hint Generation time: {}ms", ctx->HintsDuration.count()); + return true; } \ No newline at end of file diff --git a/soh/soh/Enhancements/randomizer/3drando/playthrough.cpp b/soh/soh/Enhancements/randomizer/3drando/playthrough.cpp index ef656120579..c5d78717d3a 100644 --- a/soh/soh/Enhancements/randomizer/3drando/playthrough.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/playthrough.cpp @@ -25,7 +25,9 @@ int Playthrough_Init(uint32_t seed, std::set excludedLocations, ctx->ItemReset(); ctx->HintReset(); ctx->GetLogic()->Reset(); + ctx->areaResetStart = std::chrono::high_resolution_clock::now(); Areas::AccessReset(); + ctx->areaResetEnd = std::chrono::high_resolution_clock::now(); ctx->GetSettings()->FinalizeSettings(excludedLocations, enabledTricks); // once the settings have been finalized turn them into a string for hashing @@ -71,11 +73,13 @@ int Playthrough_Init(uint32_t seed, std::set excludedLocations, //TODO: Handle different types of file output (i.e. Spoiler Log, Plando Template, Patch Files, Race Files, etc.) // write logs SPDLOG_INFO("Writing Spoiler Log..."); + ctx->logStart = std::chrono::high_resolution_clock::now(); if (SpoilerLog_Write()) { SPDLOG_INFO("Writing Spoiler Log Done"); } else { SPDLOG_ERROR("Writing Spoiler Log Failed"); } + ctx->logEnd = std::chrono::high_resolution_clock::now(); #ifdef ENABLE_DEBUG SPDLOG_INFO("Writing Placement Log..."); if (PlacementLog_Write()) { diff --git a/soh/soh/Enhancements/randomizer/context.h b/soh/soh/Enhancements/randomizer/context.h index 13147143eb9..7556ab94f76 100644 --- a/soh/soh/Enhancements/randomizer/context.h +++ b/soh/soh/Enhancements/randomizer/context.h @@ -123,6 +123,30 @@ class Context { void SetEventChkInf(int32_t flag, bool state); uint8_t GetAmmo(uint32_t item); void SetAmmo(uint32_t item, uint8_t count); + std::chrono::_V2::system_clock::time_point metricStart; + std::chrono::_V2::system_clock::time_point SCLResetStart; + std::chrono::_V2::system_clock::time_point SCLResetEnd; + std::chrono::_V2::system_clock::time_point LogicResetStart; + std::chrono::_V2::system_clock::time_point LogicResetEnd; + std::chrono::_V2::system_clock::time_point areaResetStart; + std::chrono::_V2::system_clock::time_point areaResetEnd; + std::chrono::duration updateHelpersDuration; + std::chrono::_V2::system_clock::time_point logStart; + std::chrono::_V2::system_clock::time_point logEnd; + std::chrono::duration entranceShuffleDuration; + std::chrono::duration setAreasDuration; + std::chrono::duration shopDuration; + std::chrono::duration dungeonsDuration; + std::chrono::duration limitedDuration; + std::chrono::duration advancmentDuration; + std::chrono::duration remainingDuration; + std::chrono::duration playthroughDuration; + std::chrono::duration pareDownDuration; + std::chrono::duration WotHDuration; + std::chrono::duration FoolishDuration; + std::chrono::duration OverridesDuration; + std::chrono::duration HintsDuration; + private: static std::weak_ptr mContext; diff --git a/soh/soh/Enhancements/randomizer/logic.cpp b/soh/soh/Enhancements/randomizer/logic.cpp index 231799baf68..d707d491065 100644 --- a/soh/soh/Enhancements/randomizer/logic.cpp +++ b/soh/soh/Enhancements/randomizer/logic.cpp @@ -455,6 +455,7 @@ namespace Rando { // Updates all logic helpers. Should be called whenever a non-helper is changed void Logic::UpdateHelpers() { + auto helperMetricStart = std::chrono::high_resolution_clock::now(); OcarinaButtons = (HasItem(RG_OCARINA_A_BUTTON) ? 1 : 0) + (HasItem(RG_OCARINA_C_LEFT_BUTTON) ? 1 : 0) + (HasItem(RG_OCARINA_C_RIGHT_BUTTON) ? 1 : 0) + @@ -659,6 +660,8 @@ namespace Rando { (ctx->GetSettings()->LACSCondition() == RO_LACS_DUNGEONS && DungeonCount + (Greg && GregInLacsLogic ? 1 : 0) >= ctx->GetOption(RSK_LACS_DUNGEON_COUNT).Value()) || (ctx->GetSettings()->LACSCondition() == RO_LACS_TOKENS && GoldSkulltulaTokens >= ctx->GetOption(RSK_LACS_TOKEN_COUNT).Value()); CanCompleteTriforce = TriforcePieces >= ctx->GetOption(RSK_TRIFORCE_HUNT_PIECES_REQUIRED).Value(); + auto helperMetricEnd = std::chrono::high_resolution_clock::now(); + ctx->updateHelpersDuration += (helperMetricEnd - helperMetricStart); } bool Logic::SmallKeys(RandomizerRegion dungeon, uint8_t requiredAmount) { @@ -775,7 +778,10 @@ namespace Rando { } void Logic::Reset() { + ctx->SCLResetStart = std::chrono::high_resolution_clock::now(); ctx->NewSaveContext(); + ctx->SCLResetStart = std::chrono::high_resolution_clock::now(); + ctx->LogicResetStart = std::chrono::high_resolution_clock::now(); memset(inLogic, false, sizeof(inLogic)); //Settings-dependent variables IsKeysanity = ctx->GetOption(RSK_KEYSANITY).Is(RO_DUNGEON_ITEM_LOC_ANYWHERE) || @@ -1116,5 +1122,8 @@ namespace Rando { LightTrialClearPast = false; BuyDekuShieldPast = false; TimeTravelPast = false; + + + ctx->LogicResetEnd = std::chrono::high_resolution_clock::now(); } } From 2e83a8ddf42b8ce524f67b5a0d45f4c9e8de5653 Mon Sep 17 00:00:00 2001 From: Pepper0ni <93387759+Pepper0ni@users.noreply.github.com> Date: Wed, 18 Sep 2024 21:57:33 +0100 Subject: [PATCH 2/8] push to test other platforms, add benchmark preset --- soh/soh/Enhancements/presets.h | 122 ++++++++++++++++++ .../Enhancements/randomizer/3drando/fill.cpp | 24 ++-- soh/soh/Enhancements/randomizer/context.h | 18 +-- 3 files changed, 143 insertions(+), 21 deletions(-) diff --git a/soh/soh/Enhancements/presets.h b/soh/soh/Enhancements/presets.h index 39cd167c22b..5a4b2443cc3 100644 --- a/soh/soh/Enhancements/presets.h +++ b/soh/soh/Enhancements/presets.h @@ -34,6 +34,7 @@ enum RandomizerPreset { RANDOMIZER_PRESET_SPOCK_RACE_NO_LOGIC, RANDOMIZER_PRESET_S6, RANDOMIZER_PRESET_HELL_MODE, + RANDOMIZER_PRESET_BENCHMARK, }; typedef struct PresetEntry { @@ -1147,6 +1148,122 @@ const std::vector hellModePresetEntries = { PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("ZorasFountain"), 2), }; +const std::vector BenchmarkPresetEntries = { + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("Forest"), RO_FOREST_CLOSED_DEKU), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("KakarikoGate"), RO_KAK_GATE_OPEN), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("DoorOfTime"), RO_DOOROFTIME_SONGONLY), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("ZorasFountain"), RO_ZF_CLOSED), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("GerudoFortress"), RO_GF_NORMAL), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("RainbowBridge"), RO_BRIDGE_DUNGEON_REWARDS), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("RewardCount"), 5), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("BridgeRewardOptions"), RO_BRIDGE_GREG_REWARD), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("GanonTrial"), RO_GANONS_TRIALS_SET_NUMBER), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("GanonTrialCount"), 6), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("StartingAge"), RO_AGE_RANDOM), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("ShuffleDungeonsEntrances"), RO_DUNGEON_ENTRANCE_SHUFFLE_ON), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("ShuffleBossEntrances"), RO_BOSS_ROOM_ENTRANCE_SHUFFLE_FULL), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("ShuffleOverworldEntrances"), RO_GENERIC_OFF), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("ShuffleInteriorsEntrances"), RO_INTERIOR_ENTRANCE_SHUFFLE_OFF), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("ShuffleGrottosEntrances"), RO_GENERIC_ON), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("ShuffleWarpSongs"), RO_GENERIC_ON), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("ShuffleOverworldSpawns"), RO_GENERIC_ON), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("MixedEntrances"), RO_GENERIC_OFF), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("DecoupleEntrances"), RO_GENERIC_OFF), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("BombchusInLogic"), RO_GENERIC_ON), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("EnableBombchuDrops"), RO_GENERIC_ON), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("TriforceHunt"), RO_GENERIC_OFF), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("MQDungeons"), RO_MQ_DUNGEONS_RANDOM_NUMBER), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("MQDungeonsSelection"), RO_GENERIC_OFF), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("ShuffleDungeonReward"), RO_DUNGEON_REWARDS_END_OF_DUNGEON), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("LinksPocket"), RO_LINKS_POCKET_DUNGEON_REWARD), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("ShuffleSongs"), RO_SONG_SHUFFLE_ANYWHERE), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("Shopsanity"), RO_SHOPSANITY_FOUR_ITEMS), + //RANDOTODO add refactored price/scrub/merchant settings + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("ShuffleTokens"), RO_TOKENSANITY_OFF), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("ShuffleBeehives"), RO_GENERIC_ON), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("ShuffleCows"), RO_GENERIC_ON), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("ShuffleKokiriSword"), RO_GENERIC_ON), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("ShuffleMasterSword"), RO_GENERIC_ON), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("ShuffleChildWallet"), RO_GENERIC_ON), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("ShuffleOcarinas"), RO_GENERIC_ON), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("ShuffleOcarinaButtons"), RO_GENERIC_OFF), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("ShuffleSwim"), RO_GENERIC_ON), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("ShuffleGerudoToken"), RO_GENERIC_ON), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("ShuffleFrogSongRupees"), RO_GENERIC_ON), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("ShuffleAdultTrade"), RO_GENERIC_ON), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("Shuffle100GSReward"), RO_GENERIC_OFF), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("ShuffleBossSouls"), RO_BOSS_SOULS_OFF), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("ShuffleDekuStickBag"), RO_GENERIC_ON), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("ShuffleDekuNutBag"), RO_GENERIC_ON), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("Fishsanity"), RO_FISHSANITY_BOTH), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("FishsanityAgeSplit"), RO_GENERIC_OFF), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("StartingMapsCompasses"), RO_DUNGEON_ITEM_LOC_OWN_DUNGEON), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("GerudoKeys"), RO_GERUDO_KEYS_ANYWHERE), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("BossKeysanity"), RO_DUNGEON_ITEM_LOC_OWN_DUNGEON), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("ShuffleGanonBossKey"), RO_GANON_BOSS_KEY_LACS_MEDALLIONS), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("LacsMedallionCount"), 6), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("ShuffleKeyRings"), RO_KEYRINGS_OFF), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("SkipChildZelda"), RO_GENERIC_ON), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("SkipEponaRace"), RO_GENERIC_ON), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("SkipScarecrowsSong"), RO_GENERIC_ON), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("BigPoeTargetCount"), 1), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("CuccosToReturn"), 4), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("CompleteMaskQuest"), RO_GENERIC_ON), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("GossipStoneHints"), RO_GOSSIP_STONES_NEED_NOTHING), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("HintClarity"), RO_HINT_CLARITY_CLEAR), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("HintDistribution"), RO_HINT_DIST_STRONG), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("AltarHint"), RO_GENERIC_ON), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("GanondorfHint"), RO_GENERIC_ON), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("SheikLAHint"), RO_GENERIC_ON), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("DampeHint"), RO_GENERIC_OFF), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("GregHint"), RO_GENERIC_ON), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("SariaHint"), RO_GENERIC_OFF), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("FrogsHint"), RO_GENERIC_ON), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("OoTHint"), RO_GENERIC_ON), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("BiggoronHint"), RO_GENERIC_ON), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("BigPoesHint"), RO_GENERIC_OFF), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("ChickensHint"), RO_GENERIC_ON), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("MalonHint"), RO_GENERIC_ON), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("HBAHint"), RO_GENERIC_OFF), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("WarpSongText"), RO_GENERIC_ON), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("ScrubText"), RO_GENERIC_ON), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("10GSHint"), RO_GENERIC_ON), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("20GSHint"), RO_GENERIC_ON), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("30GSHint"), RO_GENERIC_ON), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("40GSHint"), RO_GENERIC_ON), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("50GSHint"), RO_GENERIC_ON), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("MaskShopHint"), RO_GENERIC_ON), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("BlueFireArrows"), RO_GENERIC_ON), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("SunlightArrows"), RO_GENERIC_ON), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("InfiniteUpgrades"), RO_INF_UPGRADES_PROGRESSIVE), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("SkeletonKey"), RO_GENERIC_OFF), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("ItemPool"), RO_ITEM_POOL_BALANCED), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("IceTraps"), RO_ICE_TRAPS_NORMAL), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("StartingOcarina"), RO_STARTING_OCARINA_FAIRY), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("StartingDekuShield"), RO_GENERIC_ON), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("StartingKokiriSword"), RO_GENERIC_OFF), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("StartingMasterSword"), RO_GENERIC_OFF), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("StartingConsumables"), RO_GENERIC_ON), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("FullWallets"), RO_GENERIC_ON), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("StartingZeldasLullaby"), RO_GENERIC_OFF), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("StartingEponasSong"), RO_GENERIC_OFF), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("StartingSariasSong"), RO_GENERIC_OFF), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("StartingSunsSong"), RO_GENERIC_OFF), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("StartingSongOfTime"), RO_GENERIC_OFF), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("StartingSongOfStorms"), RO_GENERIC_OFF), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("StartingMinuetOfForest"), RO_GENERIC_OFF), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("StartingBoleroOfFire"), RO_GENERIC_OFF), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("StartingSerenadeOfWater"), RO_GENERIC_OFF), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("StartingRequiemOfSpirit"), RO_GENERIC_OFF), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("StartingNocturneOfShadow"), RO_GENERIC_OFF), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("StartingPreludeOfLight"), RO_GENERIC_OFF), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("StartingSkulltulaToken"), 0), + PRESET_ENTRY_S32("gRandomizeStartingHearts", 2), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("LogicRules"), RO_LOGIC_GLITCHLESS), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("AllLocationsReachable"), RO_GENERIC_ON), + PRESET_ENTRY_S32(CVAR_RANDOMIZER_SETTING("GsExpectSunsSong"), RO_GENERIC_ON), +}; + typedef struct PresetDefinition { const char* label; const char* description; @@ -1220,5 +1337,10 @@ const std::map presetTypes = { "All settings maxed but still using glitchless logic. Expect pain.", hellModePresetEntries } }, + { RANDOMIZER_PRESET_BENCHMARK, { + "Benchmark", + "Used for benchmarking the logic.", + BenchmarkPresetEntries + } }, } } } }; diff --git a/soh/soh/Enhancements/randomizer/3drando/fill.cpp b/soh/soh/Enhancements/randomizer/3drando/fill.cpp index c7995445e33..f9831828ef8 100644 --- a/soh/soh/Enhancements/randomizer/3drando/fill.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/fill.cpp @@ -1149,7 +1149,7 @@ int Fill() { //Temporarily add shop items to the ItemPool so that entrance randomization //can validate the world using deku/hylian shields - std::chrono::_V2::system_clock::time_point metricStart = std::chrono::high_resolution_clock::now(); + std::chrono::system_clock::time_point metricStart = std::chrono::high_resolution_clock::now(); AddElementsToPool(ItemPool, GetMinVanillaShopItems(32)); //assume worst case shopsanity 4 if (ctx->GetOption(RSK_SHUFFLE_ENTRANCES)) { SPDLOG_INFO("Shuffling Entrances..."); @@ -1160,10 +1160,10 @@ int Fill() { } SPDLOG_INFO("Shuffling Entrances Done"); } - std::chrono::_V2::system_clock::time_point entranceToAreaTime = std::chrono::high_resolution_clock::now(); + std::chrono::system_clock::time_point entranceToAreaTime = std::chrono::high_resolution_clock::now(); ctx->entranceShuffleDuration += (entranceToAreaTime - metricStart); SetAreas(); - std::chrono::_V2::system_clock::time_point areaToShopTime = std::chrono::high_resolution_clock::now(); + std::chrono::system_clock::time_point areaToShopTime = std::chrono::high_resolution_clock::now(); ctx->setAreasDuration += (areaToShopTime - entranceToAreaTime); //erase temporary shop items FilterAndEraseFromPool(ItemPool, [](const auto item) { return Rando::StaticData::RetrieveItem(item).GetItemType() == ITEMTYPE_SHOP; }); @@ -1216,7 +1216,7 @@ int Fill() { //Place the shop items which will still be at shop locations AssumedFill(shopItems, shopLocations); } - std::chrono::_V2::system_clock::time_point shopToDungeonsTime = std::chrono::high_resolution_clock::now(); + std::chrono::system_clock::time_point shopToDungeonsTime = std::chrono::high_resolution_clock::now(); ctx->shopDuration += (shopToDungeonsTime - areaToShopTime); //Place dungeon rewards @@ -1228,7 +1228,7 @@ int Fill() { RandomizeOwnDungeon(dungeon); } - std::chrono::_V2::system_clock::time_point dungeonsToLimitedTime = std::chrono::high_resolution_clock::now(); + std::chrono::system_clock::time_point dungeonsToLimitedTime = std::chrono::high_resolution_clock::now(); ctx->dungeonsDuration += (dungeonsToLimitedTime - shopToDungeonsTime); //Then Place songs if song shuffle is set to specific locations @@ -1260,7 +1260,7 @@ int Fill() { //Then place Link's Pocket Item if it has to be an advancement item RandomizeLinksPocket(); - std::chrono::_V2::system_clock::time_point limitedToAdvancmentTime = std::chrono::high_resolution_clock::now(); + std::chrono::system_clock::time_point limitedToAdvancmentTime = std::chrono::high_resolution_clock::now(); ctx->limitedDuration += (limitedToAdvancmentTime - dungeonsToLimitedTime); SPDLOG_INFO("Shuffling Advancement Items"); @@ -1269,7 +1269,7 @@ int Fill() { FilterAndEraseFromPool(ItemPool, [](const auto i) { return Rando::StaticData::RetrieveItem(i).IsAdvancement(); }); AssumedFill(remainingAdvancementItems, ctx->allLocations, true); - std::chrono::_V2::system_clock::time_point advancmentToRemainingTime = std::chrono::high_resolution_clock::now(); + std::chrono::system_clock::time_point advancmentToRemainingTime = std::chrono::high_resolution_clock::now(); ctx->advancmentDuration += (advancmentToRemainingTime - limitedToAdvancmentTime); //Fast fill for the rest of the pool @@ -1305,25 +1305,25 @@ int Fill() { metricStart = std::chrono::high_resolution_clock::now(); GeneratePlaythrough(); - std::chrono::_V2::system_clock::time_point playthroughEnd = std::chrono::high_resolution_clock::now(); + std::chrono::system_clock::time_point playthroughEnd = std::chrono::high_resolution_clock::now(); ctx->playthroughDuration += (playthroughEnd - metricStart); //Successful placement, produced beatable result if(ctx->playthroughBeatable && !placementFailure) { SPDLOG_INFO("Calculating Playthrough..."); PareDownPlaythrough(); - std::chrono::_V2::system_clock::time_point pareDownToWoth = std::chrono::high_resolution_clock::now(); + std::chrono::system_clock::time_point pareDownToWoth = std::chrono::high_resolution_clock::now(); ctx->pareDownDuration += (pareDownToWoth - playthroughEnd); CalculateWotH(); - std::chrono::_V2::system_clock::time_point WothToFoolish = std::chrono::high_resolution_clock::now(); + std::chrono::system_clock::time_point WothToFoolish = std::chrono::high_resolution_clock::now(); ctx->WotHDuration += (WothToFoolish - pareDownToWoth); CalculateBarren(); SPDLOG_INFO("Calculating Playthrough Done"); - std::chrono::_V2::system_clock::time_point foolishToOverrides = std::chrono::high_resolution_clock::now(); + std::chrono::system_clock::time_point foolishToOverrides = std::chrono::high_resolution_clock::now(); ctx->FoolishDuration += (foolishToOverrides - WothToFoolish); ctx->CreateItemOverrides(); ctx->GetEntranceShuffler()->CreateEntranceOverrides(); - std::chrono::_V2::system_clock::time_point overridesToHints = std::chrono::high_resolution_clock::now(); + std::chrono::system_clock::time_point overridesToHints = std::chrono::high_resolution_clock::now(); ctx->OverridesDuration += (overridesToHints - foolishToOverrides); CreateAllHints(); CreateWarpSongTexts(); diff --git a/soh/soh/Enhancements/randomizer/context.h b/soh/soh/Enhancements/randomizer/context.h index 7556ab94f76..d162bc19c51 100644 --- a/soh/soh/Enhancements/randomizer/context.h +++ b/soh/soh/Enhancements/randomizer/context.h @@ -123,16 +123,16 @@ class Context { void SetEventChkInf(int32_t flag, bool state); uint8_t GetAmmo(uint32_t item); void SetAmmo(uint32_t item, uint8_t count); - std::chrono::_V2::system_clock::time_point metricStart; - std::chrono::_V2::system_clock::time_point SCLResetStart; - std::chrono::_V2::system_clock::time_point SCLResetEnd; - std::chrono::_V2::system_clock::time_point LogicResetStart; - std::chrono::_V2::system_clock::time_point LogicResetEnd; - std::chrono::_V2::system_clock::time_point areaResetStart; - std::chrono::_V2::system_clock::time_point areaResetEnd; + std::chrono::system_clock::time_point metricStart; + std::chrono::system_clock::time_point SCLResetStart; + std::chrono::system_clock::time_point SCLResetEnd; + std::chrono::system_clock::time_point LogicResetStart; + std::chrono::system_clock::time_point LogicResetEnd; + std::chrono::system_clock::time_point areaResetStart; + std::chrono::system_clock::time_point areaResetEnd; std::chrono::duration updateHelpersDuration; - std::chrono::_V2::system_clock::time_point logStart; - std::chrono::_V2::system_clock::time_point logEnd; + std::chrono::system_clock::time_point logStart; + std::chrono::system_clock::time_point logEnd; std::chrono::duration entranceShuffleDuration; std::chrono::duration setAreasDuration; std::chrono::duration shopDuration; From 5baa346da3e7e2a6a028472022be72b6cea8bd95 Mon Sep 17 00:00:00 2001 From: Pepper0ni <93387759+Pepper0ni@users.noreply.github.com> Date: Wed, 18 Sep 2024 22:23:14 +0100 Subject: [PATCH 3/8] more other compiler fixes --- .../Enhancements/randomizer/3drando/fill.cpp | 24 +++++++++---------- soh/soh/Enhancements/randomizer/context.h | 18 +++++++------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/soh/soh/Enhancements/randomizer/3drando/fill.cpp b/soh/soh/Enhancements/randomizer/3drando/fill.cpp index f9831828ef8..9a2aee4ec39 100644 --- a/soh/soh/Enhancements/randomizer/3drando/fill.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/fill.cpp @@ -1149,7 +1149,7 @@ int Fill() { //Temporarily add shop items to the ItemPool so that entrance randomization //can validate the world using deku/hylian shields - std::chrono::system_clock::time_point metricStart = std::chrono::high_resolution_clock::now(); + std::chrono::high_resolution_clock::time_point metricStart = std::chrono::high_resolution_clock::now(); AddElementsToPool(ItemPool, GetMinVanillaShopItems(32)); //assume worst case shopsanity 4 if (ctx->GetOption(RSK_SHUFFLE_ENTRANCES)) { SPDLOG_INFO("Shuffling Entrances..."); @@ -1160,10 +1160,10 @@ int Fill() { } SPDLOG_INFO("Shuffling Entrances Done"); } - std::chrono::system_clock::time_point entranceToAreaTime = std::chrono::high_resolution_clock::now(); + std::chrono::high_resolution_clock::time_point entranceToAreaTime = std::chrono::high_resolution_clock::now(); ctx->entranceShuffleDuration += (entranceToAreaTime - metricStart); SetAreas(); - std::chrono::system_clock::time_point areaToShopTime = std::chrono::high_resolution_clock::now(); + std::chrono::high_resolution_clock::time_point areaToShopTime = std::chrono::high_resolution_clock::now(); ctx->setAreasDuration += (areaToShopTime - entranceToAreaTime); //erase temporary shop items FilterAndEraseFromPool(ItemPool, [](const auto item) { return Rando::StaticData::RetrieveItem(item).GetItemType() == ITEMTYPE_SHOP; }); @@ -1216,7 +1216,7 @@ int Fill() { //Place the shop items which will still be at shop locations AssumedFill(shopItems, shopLocations); } - std::chrono::system_clock::time_point shopToDungeonsTime = std::chrono::high_resolution_clock::now(); + std::chrono::high_resolution_clock::time_point shopToDungeonsTime = std::chrono::high_resolution_clock::now(); ctx->shopDuration += (shopToDungeonsTime - areaToShopTime); //Place dungeon rewards @@ -1228,7 +1228,7 @@ int Fill() { RandomizeOwnDungeon(dungeon); } - std::chrono::system_clock::time_point dungeonsToLimitedTime = std::chrono::high_resolution_clock::now(); + std::chrono::high_resolution_clock::time_point dungeonsToLimitedTime = std::chrono::high_resolution_clock::now(); ctx->dungeonsDuration += (dungeonsToLimitedTime - shopToDungeonsTime); //Then Place songs if song shuffle is set to specific locations @@ -1260,7 +1260,7 @@ int Fill() { //Then place Link's Pocket Item if it has to be an advancement item RandomizeLinksPocket(); - std::chrono::system_clock::time_point limitedToAdvancmentTime = std::chrono::high_resolution_clock::now(); + std::chrono::high_resolution_clock::time_point limitedToAdvancmentTime = std::chrono::high_resolution_clock::now(); ctx->limitedDuration += (limitedToAdvancmentTime - dungeonsToLimitedTime); SPDLOG_INFO("Shuffling Advancement Items"); @@ -1269,7 +1269,7 @@ int Fill() { FilterAndEraseFromPool(ItemPool, [](const auto i) { return Rando::StaticData::RetrieveItem(i).IsAdvancement(); }); AssumedFill(remainingAdvancementItems, ctx->allLocations, true); - std::chrono::system_clock::time_point advancmentToRemainingTime = std::chrono::high_resolution_clock::now(); + std::chrono::high_resolution_clock::time_point advancmentToRemainingTime = std::chrono::high_resolution_clock::now(); ctx->advancmentDuration += (advancmentToRemainingTime - limitedToAdvancmentTime); //Fast fill for the rest of the pool @@ -1305,25 +1305,25 @@ int Fill() { metricStart = std::chrono::high_resolution_clock::now(); GeneratePlaythrough(); - std::chrono::system_clock::time_point playthroughEnd = std::chrono::high_resolution_clock::now(); + std::chrono::high_resolution_clock::time_point playthroughEnd = std::chrono::high_resolution_clock::now(); ctx->playthroughDuration += (playthroughEnd - metricStart); //Successful placement, produced beatable result if(ctx->playthroughBeatable && !placementFailure) { SPDLOG_INFO("Calculating Playthrough..."); PareDownPlaythrough(); - std::chrono::system_clock::time_point pareDownToWoth = std::chrono::high_resolution_clock::now(); + std::chrono::high_resolution_clock::time_point pareDownToWoth = std::chrono::high_resolution_clock::now(); ctx->pareDownDuration += (pareDownToWoth - playthroughEnd); CalculateWotH(); - std::chrono::system_clock::time_point WothToFoolish = std::chrono::high_resolution_clock::now(); + std::chrono::high_resolution_clock::time_point WothToFoolish = std::chrono::high_resolution_clock::now(); ctx->WotHDuration += (WothToFoolish - pareDownToWoth); CalculateBarren(); SPDLOG_INFO("Calculating Playthrough Done"); - std::chrono::system_clock::time_point foolishToOverrides = std::chrono::high_resolution_clock::now(); + std::chrono::high_resolution_clock::time_point foolishToOverrides = std::chrono::high_resolution_clock::now(); ctx->FoolishDuration += (foolishToOverrides - WothToFoolish); ctx->CreateItemOverrides(); ctx->GetEntranceShuffler()->CreateEntranceOverrides(); - std::chrono::system_clock::time_point overridesToHints = std::chrono::high_resolution_clock::now(); + std::chrono::high_resolution_clock::time_point overridesToHints = std::chrono::high_resolution_clock::now(); ctx->OverridesDuration += (overridesToHints - foolishToOverrides); CreateAllHints(); CreateWarpSongTexts(); diff --git a/soh/soh/Enhancements/randomizer/context.h b/soh/soh/Enhancements/randomizer/context.h index d162bc19c51..6282c647d97 100644 --- a/soh/soh/Enhancements/randomizer/context.h +++ b/soh/soh/Enhancements/randomizer/context.h @@ -123,16 +123,16 @@ class Context { void SetEventChkInf(int32_t flag, bool state); uint8_t GetAmmo(uint32_t item); void SetAmmo(uint32_t item, uint8_t count); - std::chrono::system_clock::time_point metricStart; - std::chrono::system_clock::time_point SCLResetStart; - std::chrono::system_clock::time_point SCLResetEnd; - std::chrono::system_clock::time_point LogicResetStart; - std::chrono::system_clock::time_point LogicResetEnd; - std::chrono::system_clock::time_point areaResetStart; - std::chrono::system_clock::time_point areaResetEnd; + std::chrono::high_resolution_clock::time_point metricStart; + std::chrono::high_resolution_clock::time_point SCLResetStart; + std::chrono::high_resolution_clock::time_point SCLResetEnd; + std::chrono::high_resolution_clock::time_point LogicResetStart; + std::chrono::high_resolution_clock::time_point LogicResetEnd; + std::chrono::high_resolution_clock::time_point areaResetStart; + std::chrono::high_resolution_clock::time_point areaResetEnd; std::chrono::duration updateHelpersDuration; - std::chrono::system_clock::time_point logStart; - std::chrono::system_clock::time_point logEnd; + std::chrono::high_resolution_clock::time_point logStart; + std::chrono::high_resolution_clock::time_point logEnd; std::chrono::duration entranceShuffleDuration; std::chrono::duration setAreasDuration; std::chrono::duration shopDuration; From 8a4f1a3cb13c8d010ff58d87b9182198c99404ad Mon Sep 17 00:00:00 2001 From: Pepper0ni <93387759+Pepper0ni@users.noreply.github.com> Date: Thu, 19 Sep 2024 16:59:11 +0100 Subject: [PATCH 4/8] Finish implementing benchmarks --- .../Enhancements/randomizer/3drando/fill.cpp | 66 ++++++++++--------- .../randomizer/3drando/location_access.cpp | 7 +- .../Enhancements/randomizer/3drando/menu.cpp | 62 +++++++---------- .../randomizer/3drando/playthrough.cpp | 8 +-- soh/soh/Enhancements/randomizer/context.cpp | 23 +++++++ soh/soh/Enhancements/randomizer/context.h | 30 ++------- soh/soh/Enhancements/randomizer/entrance.cpp | 33 +++++----- soh/soh/Enhancements/randomizer/logic.cpp | 12 ++-- .../Enhancements/randomizer/randomizerTypes.h | 25 +++++++ 9 files changed, 146 insertions(+), 120 deletions(-) diff --git a/soh/soh/Enhancements/randomizer/3drando/fill.cpp b/soh/soh/Enhancements/randomizer/3drando/fill.cpp index 9a2aee4ec39..cf5893a592c 100644 --- a/soh/soh/Enhancements/randomizer/3drando/fill.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/fill.cpp @@ -100,6 +100,8 @@ static void RemoveStartingItemsFromPool() { //This function will propagate Time of Day access through the entrance static bool UpdateToDAccess(Entrance* entrance, bool propagateTimeTravel) { + auto ctx = Rando::Context::GetInstance(); + ctx->StartPerformanceTimer(PT_TOD_ACCESS); bool ageTimePropogated = false; @@ -133,6 +135,7 @@ static bool UpdateToDAccess(Entrance* entrance, bool propagateTimeTravel) { AreaTable(RR_ROOT)->childNight = AreaTable(RR_TOT_BEYOND_DOOR_OF_TIME)->adultNight; } + ctx->StopPerformanceTimer(PT_TOD_ACCESS); return ageTimePropogated; } @@ -360,6 +363,7 @@ void AddToPlaythrough(LocationAccess& locPair, GetAccessableLocationsStruct& gal // Adds the contents of a location to the current progression and optionally playthrough bool AddCheckToLogic(LocationAccess& locPair, GetAccessableLocationsStruct& gals, RandomizerGet ignore, bool stopOnBeatable, bool addToPlaythrough=false){ auto ctx = Rando::Context::GetInstance(); + ctx->StartPerformanceTimer(PT_LOCATION_LOGIC); RandomizerCheck loc = locPair.GetLocation(); Rando::ItemLocation* location = ctx->GetItemLocation(loc); RandomizerGet locItem = location->GetPlacedRandomizerGet(); @@ -399,9 +403,11 @@ bool AddCheckToLogic(LocationAccess& locPair, GetAccessableLocationsStruct& gals } //All we care about is if the game is beatable, used to pare down playthrough if (location->GetPlacedRandomizerGet() == RG_TRIFORCE && stopOnBeatable) { + ctx->StopPerformanceTimer(PT_LOCATION_LOGIC); return true; //Return early for efficiency } } + ctx->StopPerformanceTimer(PT_LOCATION_LOGIC); return false; } @@ -1149,7 +1155,7 @@ int Fill() { //Temporarily add shop items to the ItemPool so that entrance randomization //can validate the world using deku/hylian shields - std::chrono::high_resolution_clock::time_point metricStart = std::chrono::high_resolution_clock::now(); + ctx->StartPerformanceTimer(PT_ENTRANCE_SHUFFLE); AddElementsToPool(ItemPool, GetMinVanillaShopItems(32)); //assume worst case shopsanity 4 if (ctx->GetOption(RSK_SHUFFLE_ENTRANCES)) { SPDLOG_INFO("Shuffling Entrances..."); @@ -1160,16 +1166,15 @@ int Fill() { } SPDLOG_INFO("Shuffling Entrances Done"); } - std::chrono::high_resolution_clock::time_point entranceToAreaTime = std::chrono::high_resolution_clock::now(); - ctx->entranceShuffleDuration += (entranceToAreaTime - metricStart); SetAreas(); - std::chrono::high_resolution_clock::time_point areaToShopTime = std::chrono::high_resolution_clock::now(); - ctx->setAreasDuration += (areaToShopTime - entranceToAreaTime); //erase temporary shop items FilterAndEraseFromPool(ItemPool, [](const auto item) { return Rando::StaticData::RetrieveItem(item).GetItemType() == ITEMTYPE_SHOP; }); + ctx->StopPerformanceTimer(PT_ENTRANCE_SHUFFLE); //ctx->showItemProgress = true; //Place shop items first, since a buy shield is needed to place a dungeon reward on Gohma due to access + + ctx->StartPerformanceTimer(PT_SHOPSANITY); NonShopItems = {}; if (ctx->GetOption(RSK_SHOPSANITY).Is(RO_SHOPSANITY_OFF)) { SPDLOG_INFO("Placing Vanilla Shop Items..."); @@ -1216,9 +1221,9 @@ int Fill() { //Place the shop items which will still be at shop locations AssumedFill(shopItems, shopLocations); } - std::chrono::high_resolution_clock::time_point shopToDungeonsTime = std::chrono::high_resolution_clock::now(); - ctx->shopDuration += (shopToDungeonsTime - areaToShopTime); + ctx->StopPerformanceTimer(PT_SHOPSANITY); + ctx->StartPerformanceTimer(PT_OWN_DUNGEON); //Place dungeon rewards SPDLOG_INFO("Shuffling and Placing Dungeon Items..."); RandomizeDungeonRewards(); @@ -1227,10 +1232,9 @@ int Fill() { for (auto dungeon : ctx->GetDungeons()->GetDungeonList()) { RandomizeOwnDungeon(dungeon); } + ctx->StopPerformanceTimer(PT_OWN_DUNGEON); - std::chrono::high_resolution_clock::time_point dungeonsToLimitedTime = std::chrono::high_resolution_clock::now(); - ctx->dungeonsDuration += (dungeonsToLimitedTime - shopToDungeonsTime); - + ctx->StartPerformanceTimer(PT_LIMITED_CHECKS); //Then Place songs if song shuffle is set to specific locations if (ctx->GetOption(RSK_SHUFFLE_SONGS).IsNot(RO_SONG_SHUFFLE_ANYWHERE)) { @@ -1259,25 +1263,23 @@ int Fill() { //Then place Link's Pocket Item if it has to be an advancement item RandomizeLinksPocket(); + ctx->StopPerformanceTimer(PT_LIMITED_CHECKS); - std::chrono::high_resolution_clock::time_point limitedToAdvancmentTime = std::chrono::high_resolution_clock::now(); - ctx->limitedDuration += (limitedToAdvancmentTime - dungeonsToLimitedTime); + ctx->StartPerformanceTimer(PT_ADVANCEMENT_ITEMS); SPDLOG_INFO("Shuffling Advancement Items"); //Then place the rest of the advancement items std::vector remainingAdvancementItems = FilterAndEraseFromPool(ItemPool, [](const auto i) { return Rando::StaticData::RetrieveItem(i).IsAdvancement(); }); AssumedFill(remainingAdvancementItems, ctx->allLocations, true); + ctx->StopPerformanceTimer(PT_ADVANCEMENT_ITEMS); - std::chrono::high_resolution_clock::time_point advancmentToRemainingTime = std::chrono::high_resolution_clock::now(); - ctx->advancmentDuration += (advancmentToRemainingTime - limitedToAdvancmentTime); - + ctx->StartPerformanceTimer(PT_REMAINING_ITEMS); //Fast fill for the rest of the pool SPDLOG_INFO("Shuffling Remaining Items"); std::vector remainingPool = FilterAndEraseFromPool(ItemPool, [](const auto i) { return true; }); FastFill(remainingPool, GetAllEmptyLocations(), false); - - ctx->remainingDuration += (std::chrono::high_resolution_clock::now() - advancmentToRemainingTime); + ctx->StopPerformanceTimer(PT_REMAINING_ITEMS); //Add default prices to scrubs for (size_t i = 0; i < Rando::StaticData::scrubLocations.size(); i++) { @@ -1303,31 +1305,35 @@ int Fill() { } } - metricStart = std::chrono::high_resolution_clock::now(); + ctx->StartPerformanceTimer(PT_PLAYTHROUGH_GENERATION); GeneratePlaythrough(); - std::chrono::high_resolution_clock::time_point playthroughEnd = std::chrono::high_resolution_clock::now(); - ctx->playthroughDuration += (playthroughEnd - metricStart); + ctx->StopPerformanceTimer(PT_PLAYTHROUGH_GENERATION); //Successful placement, produced beatable result if(ctx->playthroughBeatable && !placementFailure) { + SPDLOG_INFO("Calculating Playthrough..."); + ctx->StartPerformanceTimer(PT_PARE_DOWN_PLAYTHROUGH); PareDownPlaythrough(); - std::chrono::high_resolution_clock::time_point pareDownToWoth = std::chrono::high_resolution_clock::now(); - ctx->pareDownDuration += (pareDownToWoth - playthroughEnd); + ctx->StopPerformanceTimer(PT_PARE_DOWN_PLAYTHROUGH); + + ctx->StartPerformanceTimer(PT_WOTH); CalculateWotH(); - std::chrono::high_resolution_clock::time_point WothToFoolish = std::chrono::high_resolution_clock::now(); - ctx->WotHDuration += (WothToFoolish - pareDownToWoth); + ctx->StopPerformanceTimer(PT_WOTH); + + ctx->StartPerformanceTimer(PT_FOOLISH); CalculateBarren(); + ctx->StopPerformanceTimer(PT_FOOLISH); SPDLOG_INFO("Calculating Playthrough Done"); - std::chrono::high_resolution_clock::time_point foolishToOverrides = std::chrono::high_resolution_clock::now(); - ctx->FoolishDuration += (foolishToOverrides - WothToFoolish); + + ctx->StartPerformanceTimer(PT_OVERRIDES); ctx->CreateItemOverrides(); ctx->GetEntranceShuffler()->CreateEntranceOverrides(); - - std::chrono::high_resolution_clock::time_point overridesToHints = std::chrono::high_resolution_clock::now(); - ctx->OverridesDuration += (overridesToHints - foolishToOverrides); + ctx->StopPerformanceTimer(PT_OVERRIDES); + + ctx->StartPerformanceTimer(PT_HINTS); CreateAllHints(); CreateWarpSongTexts(); - ctx->HintsDuration += (std::chrono::high_resolution_clock::now() - overridesToHints); + ctx->StopPerformanceTimer(PT_HINTS); return 1; } //Unsuccessful placement diff --git a/soh/soh/Enhancements/randomizer/3drando/location_access.cpp b/soh/soh/Enhancements/randomizer/3drando/location_access.cpp index 851c26a4849..555abbd19a2 100644 --- a/soh/soh/Enhancements/randomizer/3drando/location_access.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/location_access.cpp @@ -90,7 +90,9 @@ Area::Area(std::string regionName_, std::string scene_, RandomizerArea area, Area::~Area() = default; bool Area::UpdateEvents(bool haveTimeAccess) { + auto ctx = Rando::Context::GetInstance(); if (timePass && haveTimeAccess) { + ctx->StartPerformanceTimer(PT_TOD_ACCESS); if (Child()) { childDay = true; childNight = true; @@ -103,11 +105,13 @@ bool Area::UpdateEvents(bool haveTimeAccess) { AreaTable(RR_ROOT)->adultDay = true; AreaTable(RR_ROOT)->adultNight = true; } + ctx->StopPerformanceTimer(PT_TOD_ACCESS); } bool eventsUpdated = false; - + ctx->StartPerformanceTimer(PT_EVENT_ACCESS); for (EventAccess& event : events) { + //If the event has already happened, there's no reason to check it if (event.GetEvent()) { continue; @@ -121,6 +125,7 @@ bool Area::UpdateEvents(bool haveTimeAccess) { eventsUpdated = true; } } + ctx->StopPerformanceTimer(PT_EVENT_ACCESS); return eventsUpdated; } diff --git a/soh/soh/Enhancements/randomizer/3drando/menu.cpp b/soh/soh/Enhancements/randomizer/3drando/menu.cpp index dc58506f368..72eb1c95cf7 100644 --- a/soh/soh/Enhancements/randomizer/3drando/menu.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/menu.cpp @@ -24,20 +24,7 @@ Rando::Option* currentSetting; bool GenerateRandomizer(std::set excludedLocations, std::set enabledTricks, std::string seedInput) { const auto ctx = Rando::Context::GetInstance(); - ctx->metricStart = std::chrono::high_resolution_clock::now(); - ctx->updateHelpersDuration = std::chrono::milliseconds(0); - ctx->entranceShuffleDuration = std::chrono::milliseconds(0); - ctx->shopDuration = std::chrono::milliseconds(0); - ctx->dungeonsDuration = std::chrono::milliseconds(0); - ctx->limitedDuration = std::chrono::milliseconds(0); - ctx->advancmentDuration = std::chrono::milliseconds(0); - ctx->remainingDuration = std::chrono::milliseconds(0); - ctx->playthroughDuration = std::chrono::milliseconds(0); - ctx->pareDownDuration = std::chrono::milliseconds(0); - ctx->WotHDuration = std::chrono::milliseconds(0); - ctx->FoolishDuration = std::chrono::milliseconds(0); - ctx->OverridesDuration = std::chrono::milliseconds(0); - ctx->HintsDuration = std::chrono::milliseconds(0); + ctx->StartPerformanceTimer(PT_WHOLE_SEED); srand(time(NULL)); // if a blank seed was entered, make a random one @@ -80,30 +67,27 @@ bool GenerateRandomizer(std::set excludedLocations, std::setGetOption(RSK_KEYSANITY).RestoreDelayedOption(); } - std::chrono::duration duration = std::chrono::high_resolution_clock::now() - ctx->metricStart; - SPDLOG_DEBUG("Full Seed Genration Time: {}ms", duration.count()); - duration = ctx->SCLResetEnd - ctx->SCLResetStart; - SPDLOG_DEBUG("SCL reset time: {}ms", duration.count()); - duration = ctx->LogicResetEnd - ctx->LogicResetStart; - SPDLOG_DEBUG("LogicReset time: {}ms", duration.count()); - duration = ctx->areaResetEnd - ctx->areaResetStart; - SPDLOG_DEBUG("Area->Reset time: {}ms", duration.count()); - duration = ctx->logEnd - ctx->logStart; - SPDLOG_DEBUG("SpoilerLog writing time: {}ms", duration.count()); - SPDLOG_DEBUG("Total UpdateHelpers time: {}ms", ctx->updateHelpersDuration.count()); - SPDLOG_DEBUG("Total Entrance Shuffle time: {}ms", ctx->entranceShuffleDuration.count()); - SPDLOG_DEBUG("Total SetAreas time: {}ms", ctx->setAreasDuration.count()); - SPDLOG_DEBUG("Total Shopsanity time: {}ms", ctx->shopDuration.count()); - SPDLOG_DEBUG("Total Dungeon Specific Items time: {}ms", ctx->dungeonsDuration.count()); - SPDLOG_DEBUG("Total Misc Limited Checks time: {}ms", ctx->limitedDuration.count()); - SPDLOG_DEBUG("Total Advancment Checks time: {}ms", ctx->advancmentDuration.count()); - SPDLOG_DEBUG("Total Other Checks time: {}ms", ctx->remainingDuration.count()); - SPDLOG_DEBUG("Total Playthrough Generation time: {}ms", ctx->playthroughDuration.count()); - SPDLOG_DEBUG("Total ParDownPlaythrough time: {}ms", ctx->pareDownDuration.count()); - SPDLOG_DEBUG("Total WotH generation time: {}ms", ctx->WotHDuration.count()); - SPDLOG_DEBUG("Total Foolish generation time: {}ms", ctx->FoolishDuration.count()); - SPDLOG_DEBUG("Total Overrides time: {}ms", ctx->OverridesDuration.count()); - SPDLOG_DEBUG("Total Hint Generation time: {}ms", ctx->HintsDuration.count()); - + ctx->StopPerformanceTimer(PT_WHOLE_SEED); + SPDLOG_DEBUG("Full Seed Genration Time: {}ms", ctx->GetPerformanceTimer(PT_WHOLE_SEED).count()); + SPDLOG_DEBUG("LogicReset time: {}ms", ctx->GetPerformanceTimer(PT_LOGIC_RESET).count()); + SPDLOG_DEBUG("Area->Reset time: {}ms", ctx->GetPerformanceTimer(PT_AREA_RESET).count()); + SPDLOG_DEBUG("Total Entrance Shuffle time: {}ms", ctx->GetPerformanceTimer(PT_ENTRANCE_SHUFFLE).count()); + SPDLOG_DEBUG("Total Shopsanity time: {}ms", ctx->GetPerformanceTimer(PT_SHOPSANITY).count()); + SPDLOG_DEBUG("Total Dungeon Specific Items time: {}ms", ctx->GetPerformanceTimer(PT_OWN_DUNGEON).count()); + SPDLOG_DEBUG("Total Misc Limited Checks time: {}ms", ctx->GetPerformanceTimer(PT_LIMITED_CHECKS).count()); + SPDLOG_DEBUG("Total Advancment Checks time: {}ms", ctx->GetPerformanceTimer(PT_ADVANCEMENT_ITEMS).count()); + SPDLOG_DEBUG("Total Other Checks time: {}ms", ctx->GetPerformanceTimer(PT_REMAINING_ITEMS).count()); + SPDLOG_DEBUG("Total Playthrough Generation time: {}ms", ctx->GetPerformanceTimer(PT_PLAYTHROUGH_GENERATION).count()); + SPDLOG_DEBUG("Total PareDownPlaythrough time: {}ms", ctx->GetPerformanceTimer(PT_PARE_DOWN_PLAYTHROUGH).count()); + SPDLOG_DEBUG("Total WotH generation time: {}ms", ctx->GetPerformanceTimer(PT_WOTH).count()); + SPDLOG_DEBUG("Total Foolish generation time: {}ms", ctx->GetPerformanceTimer(PT_FOOLISH).count()); + SPDLOG_DEBUG("Total Overrides time: {}ms", ctx->GetPerformanceTimer(PT_OVERRIDES).count()); + SPDLOG_DEBUG("Total Hint Generation time: {}ms", ctx->GetPerformanceTimer(PT_HINTS).count()); + SPDLOG_DEBUG("SpoilerLog writing time: {}ms", ctx->GetPerformanceTimer(PT_SPOILER_LOG).count()); + SPDLOG_DEBUG("Total UpdateHelpers time: {}ms", ctx->GetPerformanceTimer(PT_UPDATE_HELPERS).count()); + SPDLOG_DEBUG("Total Event Access Calculation time: {}ms", ctx->GetPerformanceTimer(PT_EVENT_ACCESS).count()); + SPDLOG_DEBUG("Total ToD Access Calculation: {}ms", ctx->GetPerformanceTimer(PT_TOD_ACCESS).count()); + SPDLOG_DEBUG("Total Entrance Logic Calculation time: {}ms", ctx->GetPerformanceTimer(PT_ENTRANCE_LOGIC).count()); + SPDLOG_DEBUG("Total Check Logic Calculation time: {}ms", ctx->GetPerformanceTimer(PT_LOCATION_LOGIC).count()); return true; } \ No newline at end of file diff --git a/soh/soh/Enhancements/randomizer/3drando/playthrough.cpp b/soh/soh/Enhancements/randomizer/3drando/playthrough.cpp index c5d78717d3a..f77524bd0c5 100644 --- a/soh/soh/Enhancements/randomizer/3drando/playthrough.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/playthrough.cpp @@ -25,9 +25,9 @@ int Playthrough_Init(uint32_t seed, std::set excludedLocations, ctx->ItemReset(); ctx->HintReset(); ctx->GetLogic()->Reset(); - ctx->areaResetStart = std::chrono::high_resolution_clock::now(); + ctx->StartPerformanceTimer(PT_AREA_RESET); Areas::AccessReset(); - ctx->areaResetEnd = std::chrono::high_resolution_clock::now(); + ctx->StopPerformanceTimer(PT_AREA_RESET); ctx->GetSettings()->FinalizeSettings(excludedLocations, enabledTricks); // once the settings have been finalized turn them into a string for hashing @@ -73,13 +73,13 @@ int Playthrough_Init(uint32_t seed, std::set excludedLocations, //TODO: Handle different types of file output (i.e. Spoiler Log, Plando Template, Patch Files, Race Files, etc.) // write logs SPDLOG_INFO("Writing Spoiler Log..."); - ctx->logStart = std::chrono::high_resolution_clock::now(); + ctx->StartPerformanceTimer(PT_SPOILER_LOG); if (SpoilerLog_Write()) { SPDLOG_INFO("Writing Spoiler Log Done"); } else { SPDLOG_ERROR("Writing Spoiler Log Failed"); } - ctx->logEnd = std::chrono::high_resolution_clock::now(); + ctx->StopPerformanceTimer(PT_SPOILER_LOG); #ifdef ENABLE_DEBUG SPDLOG_INFO("Writing Placement Log..."); if (PlacementLog_Write()) { diff --git a/soh/soh/Enhancements/randomizer/context.cpp b/soh/soh/Enhancements/randomizer/context.cpp index db348b32f82..f9a514de972 100644 --- a/soh/soh/Enhancements/randomizer/context.cpp +++ b/soh/soh/Enhancements/randomizer/context.cpp @@ -1221,4 +1221,27 @@ uint8_t Context::GetAmmo(uint32_t item) { void Context::SetAmmo(uint32_t item, uint8_t count) { mSaveContext->inventory.ammo[gItemSlots[item]] = count; } + +void Context::StartPerformanceTimer(PerformanceTimers timer){ + timeStarted[timer] = std::chrono::high_resolution_clock::now(); +} + +void Context::StopPerformanceTimer(PerformanceTimers timer){ + totalTimes[timer] += (std::chrono::high_resolution_clock::now() - timeStarted[timer]); +} + +std::chrono::duration Context::GetPerformanceTimer(PerformanceTimers timer){ + return totalTimes[timer]; +} + +void Context::SubtractTimerFromTimer(PerformanceTimers timer1, PerformanceTimers timer2){ + totalTimes[timer1] -= totalTimes[timer2]; +} + +void Context::ResetTimers(){ + for (auto duration : totalTimes){ + duration = std::chrono::milliseconds(0); + } +} + } // namespace Rando diff --git a/soh/soh/Enhancements/randomizer/context.h b/soh/soh/Enhancements/randomizer/context.h index 6282c647d97..380a020d7d0 100644 --- a/soh/soh/Enhancements/randomizer/context.h +++ b/soh/soh/Enhancements/randomizer/context.h @@ -123,29 +123,11 @@ class Context { void SetEventChkInf(int32_t flag, bool state); uint8_t GetAmmo(uint32_t item); void SetAmmo(uint32_t item, uint8_t count); - std::chrono::high_resolution_clock::time_point metricStart; - std::chrono::high_resolution_clock::time_point SCLResetStart; - std::chrono::high_resolution_clock::time_point SCLResetEnd; - std::chrono::high_resolution_clock::time_point LogicResetStart; - std::chrono::high_resolution_clock::time_point LogicResetEnd; - std::chrono::high_resolution_clock::time_point areaResetStart; - std::chrono::high_resolution_clock::time_point areaResetEnd; - std::chrono::duration updateHelpersDuration; - std::chrono::high_resolution_clock::time_point logStart; - std::chrono::high_resolution_clock::time_point logEnd; - std::chrono::duration entranceShuffleDuration; - std::chrono::duration setAreasDuration; - std::chrono::duration shopDuration; - std::chrono::duration dungeonsDuration; - std::chrono::duration limitedDuration; - std::chrono::duration advancmentDuration; - std::chrono::duration remainingDuration; - std::chrono::duration playthroughDuration; - std::chrono::duration pareDownDuration; - std::chrono::duration WotHDuration; - std::chrono::duration FoolishDuration; - std::chrono::duration OverridesDuration; - std::chrono::duration HintsDuration; + void StartPerformanceTimer(PerformanceTimers timer); + void StopPerformanceTimer(PerformanceTimers timer); + std::chrono::duration GetPerformanceTimer(PerformanceTimers timer); + void SubtractTimerFromTimer(PerformanceTimers timer1, PerformanceTimers timer2); + void ResetTimers(); private: @@ -162,5 +144,7 @@ class Context { bool mSeedGenerated = false; bool mSpoilerLoaded = false; bool mPlandoLoaded = false; + std::array, PT_MAX> totalTimes = {}; + std::array timeStarted = {}; }; } // namespace Rando \ No newline at end of file diff --git a/soh/soh/Enhancements/randomizer/entrance.cpp b/soh/soh/Enhancements/randomizer/entrance.cpp index 16f362cb992..110c929c7ca 100644 --- a/soh/soh/Enhancements/randomizer/entrance.cpp +++ b/soh/soh/Enhancements/randomizer/entrance.cpp @@ -70,21 +70,24 @@ void Entrance::printAgeTimeAccess() { } bool Entrance::ConditionsMet(bool allAgeTimes) const { - - Area* parent = AreaTable(parentRegion); - int conditionsMet = 0; - - if (allAgeTimes && !parent->AllAccess()) { - return false; - } - - // check all possible day/night condition combinations - conditionsMet = (parent->childDay && CheckConditionAtAgeTime(logic->IsChild, logic->AtDay, allAgeTimes)) + - (parent->childNight && CheckConditionAtAgeTime(logic->IsChild, logic->AtNight, allAgeTimes)) + - (parent->adultDay && CheckConditionAtAgeTime(logic->IsAdult, logic->AtDay, allAgeTimes)) + - (parent->adultNight && CheckConditionAtAgeTime(logic->IsAdult, logic->AtNight, allAgeTimes)); - - return conditionsMet && (!allAgeTimes || conditionsMet == 4); + auto ctx = Rando::Context::GetInstance(); + ctx->StartPerformanceTimer(PT_ENTRANCE_LOGIC); + Area* parent = AreaTable(parentRegion); + int conditionsMet = 0; + + if (allAgeTimes && !parent->AllAccess()) { + ctx->StopPerformanceTimer(PT_ENTRANCE_LOGIC); + return false; + } + + // check all possible day/night condition combinations + conditionsMet = (parent->childDay && CheckConditionAtAgeTime(logic->IsChild, logic->AtDay, allAgeTimes)) + + (parent->childNight && CheckConditionAtAgeTime(logic->IsChild, logic->AtNight, allAgeTimes)) + + (parent->adultDay && CheckConditionAtAgeTime(logic->IsAdult, logic->AtDay, allAgeTimes)) + + (parent->adultNight && CheckConditionAtAgeTime(logic->IsAdult, logic->AtNight, allAgeTimes)); + + ctx->StopPerformanceTimer(PT_ENTRANCE_LOGIC); + return conditionsMet && (!allAgeTimes || conditionsMet == 4); } uint32_t Entrance::Getuint32_t() const { diff --git a/soh/soh/Enhancements/randomizer/logic.cpp b/soh/soh/Enhancements/randomizer/logic.cpp index d707d491065..3fabfcde345 100644 --- a/soh/soh/Enhancements/randomizer/logic.cpp +++ b/soh/soh/Enhancements/randomizer/logic.cpp @@ -455,7 +455,7 @@ namespace Rando { // Updates all logic helpers. Should be called whenever a non-helper is changed void Logic::UpdateHelpers() { - auto helperMetricStart = std::chrono::high_resolution_clock::now(); + ctx->StartPerformanceTimer(PT_UPDATE_HELPERS); OcarinaButtons = (HasItem(RG_OCARINA_A_BUTTON) ? 1 : 0) + (HasItem(RG_OCARINA_C_LEFT_BUTTON) ? 1 : 0) + (HasItem(RG_OCARINA_C_RIGHT_BUTTON) ? 1 : 0) + @@ -660,8 +660,7 @@ namespace Rando { (ctx->GetSettings()->LACSCondition() == RO_LACS_DUNGEONS && DungeonCount + (Greg && GregInLacsLogic ? 1 : 0) >= ctx->GetOption(RSK_LACS_DUNGEON_COUNT).Value()) || (ctx->GetSettings()->LACSCondition() == RO_LACS_TOKENS && GoldSkulltulaTokens >= ctx->GetOption(RSK_LACS_TOKEN_COUNT).Value()); CanCompleteTriforce = TriforcePieces >= ctx->GetOption(RSK_TRIFORCE_HUNT_PIECES_REQUIRED).Value(); - auto helperMetricEnd = std::chrono::high_resolution_clock::now(); - ctx->updateHelpersDuration += (helperMetricEnd - helperMetricStart); + ctx->StopPerformanceTimer(PT_UPDATE_HELPERS); } bool Logic::SmallKeys(RandomizerRegion dungeon, uint8_t requiredAmount) { @@ -778,10 +777,8 @@ namespace Rando { } void Logic::Reset() { - ctx->SCLResetStart = std::chrono::high_resolution_clock::now(); ctx->NewSaveContext(); - ctx->SCLResetStart = std::chrono::high_resolution_clock::now(); - ctx->LogicResetStart = std::chrono::high_resolution_clock::now(); + ctx->StartPerformanceTimer(PT_LOGIC_RESET); memset(inLogic, false, sizeof(inLogic)); //Settings-dependent variables IsKeysanity = ctx->GetOption(RSK_KEYSANITY).Is(RO_DUNGEON_ITEM_LOC_ANYWHERE) || @@ -1123,7 +1120,6 @@ namespace Rando { BuyDekuShieldPast = false; TimeTravelPast = false; - - ctx->LogicResetEnd = std::chrono::high_resolution_clock::now(); + ctx->StopPerformanceTimer(PT_LOGIC_RESET); } } diff --git a/soh/soh/Enhancements/randomizer/randomizerTypes.h b/soh/soh/Enhancements/randomizer/randomizerTypes.h index 304fef213cd..753cbc2a09d 100644 --- a/soh/soh/Enhancements/randomizer/randomizerTypes.h +++ b/soh/soh/Enhancements/randomizer/randomizerTypes.h @@ -4324,4 +4324,29 @@ typedef enum { TH_MESSAGE_SURPLUS, } TriforceHuntMessages; +typedef enum { + PT_WHOLE_SEED, + PT_LOGIC_RESET, + PT_AREA_RESET, + PT_UPDATE_HELPERS, + PT_SPOILER_LOG, + PT_ENTRANCE_SHUFFLE, + PT_SHOPSANITY, + PT_OWN_DUNGEON, + PT_LIMITED_CHECKS, + PT_ADVANCEMENT_ITEMS, + PT_REMAINING_ITEMS, + PT_PLAYTHROUGH_GENERATION, + PT_PARE_DOWN_PLAYTHROUGH, + PT_WOTH, + PT_FOOLISH, + PT_OVERRIDES, + PT_HINTS, + PT_EVENT_ACCESS, + PT_TOD_ACCESS, + PT_ENTRANCE_LOGIC, + PT_LOCATION_LOGIC, + PT_MAX +} PerformanceTimers; + From 971a7d811a35c685861ced30ad464a182c500fb1 Mon Sep 17 00:00:00 2001 From: Pepper0ni <93387759+Pepper0ni@users.noreply.github.com> Date: Fri, 20 Sep 2024 20:19:55 +0100 Subject: [PATCH 5/8] forgot to reset the timers each run --- soh/soh/Enhancements/randomizer/3drando/menu.cpp | 1 + soh/soh/Enhancements/randomizer/context.cpp | 4 ---- soh/soh/Enhancements/randomizer/context.h | 1 - 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/soh/soh/Enhancements/randomizer/3drando/menu.cpp b/soh/soh/Enhancements/randomizer/3drando/menu.cpp index 72eb1c95cf7..bcfbff7433d 100644 --- a/soh/soh/Enhancements/randomizer/3drando/menu.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/menu.cpp @@ -24,6 +24,7 @@ Rando::Option* currentSetting; bool GenerateRandomizer(std::set excludedLocations, std::set enabledTricks, std::string seedInput) { const auto ctx = Rando::Context::GetInstance(); + ctx->ResetTimers(); ctx->StartPerformanceTimer(PT_WHOLE_SEED); srand(time(NULL)); diff --git a/soh/soh/Enhancements/randomizer/context.cpp b/soh/soh/Enhancements/randomizer/context.cpp index f9a514de972..197868f9c45 100644 --- a/soh/soh/Enhancements/randomizer/context.cpp +++ b/soh/soh/Enhancements/randomizer/context.cpp @@ -1234,10 +1234,6 @@ std::chrono::duration Context::GetPerformanceTimer(Performan return totalTimes[timer]; } -void Context::SubtractTimerFromTimer(PerformanceTimers timer1, PerformanceTimers timer2){ - totalTimes[timer1] -= totalTimes[timer2]; -} - void Context::ResetTimers(){ for (auto duration : totalTimes){ duration = std::chrono::milliseconds(0); diff --git a/soh/soh/Enhancements/randomizer/context.h b/soh/soh/Enhancements/randomizer/context.h index 380a020d7d0..69ddbf50005 100644 --- a/soh/soh/Enhancements/randomizer/context.h +++ b/soh/soh/Enhancements/randomizer/context.h @@ -126,7 +126,6 @@ class Context { void StartPerformanceTimer(PerformanceTimers timer); void StopPerformanceTimer(PerformanceTimers timer); std::chrono::duration GetPerformanceTimer(PerformanceTimers timer); - void SubtractTimerFromTimer(PerformanceTimers timer1, PerformanceTimers timer2); void ResetTimers(); From 5e6c90a0fb45ffe2ea9b6c47dc17aa56b2c68e7c Mon Sep 17 00:00:00 2001 From: Pepper0ni <93387759+Pepper0ni@users.noreply.github.com> Date: Fri, 20 Sep 2024 20:28:30 +0100 Subject: [PATCH 6/8] do it better --- soh/soh/Enhancements/randomizer/context.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/soh/soh/Enhancements/randomizer/context.cpp b/soh/soh/Enhancements/randomizer/context.cpp index 197868f9c45..730d2dae5de 100644 --- a/soh/soh/Enhancements/randomizer/context.cpp +++ b/soh/soh/Enhancements/randomizer/context.cpp @@ -1235,9 +1235,7 @@ std::chrono::duration Context::GetPerformanceTimer(Performan } void Context::ResetTimers(){ - for (auto duration : totalTimes){ - duration = std::chrono::milliseconds(0); - } + totalTimes = {}; } } // namespace Rando From a74cbaffae74771ff81cfddee40cdd62acbb4531 Mon Sep 17 00:00:00 2001 From: Pepper0ni <93387759+Pepper0ni@users.noreply.github.com> Date: Sat, 21 Sep 2024 18:46:12 +0100 Subject: [PATCH 7/8] move timers to thier own file --- .../Enhancements/randomizer/3drando/fill.cpp | 60 +++++++++---------- .../randomizer/3drando/location_access.cpp | 10 ++-- .../Enhancements/randomizer/3drando/menu.cpp | 49 +++++++-------- .../randomizer/3drando/playthrough.cpp | 9 +-- soh/soh/Enhancements/randomizer/context.cpp | 16 ----- soh/soh/Enhancements/randomizer/context.h | 6 -- soh/soh/Enhancements/randomizer/entrance.cpp | 7 ++- soh/soh/Enhancements/randomizer/logic.cpp | 9 +-- .../Enhancements/randomizer/randomizerTypes.h | 25 -------- 9 files changed, 74 insertions(+), 117 deletions(-) diff --git a/soh/soh/Enhancements/randomizer/3drando/fill.cpp b/soh/soh/Enhancements/randomizer/3drando/fill.cpp index cf5893a592c..a1b56c3e376 100644 --- a/soh/soh/Enhancements/randomizer/3drando/fill.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/fill.cpp @@ -14,6 +14,7 @@ #include "pool_functions.hpp" //#include "debug.hpp" #include "soh/Enhancements/randomizer/static_data.h" +#include "../../debugger/performanceTimer.h" #include #include @@ -100,8 +101,7 @@ static void RemoveStartingItemsFromPool() { //This function will propagate Time of Day access through the entrance static bool UpdateToDAccess(Entrance* entrance, bool propagateTimeTravel) { - auto ctx = Rando::Context::GetInstance(); - ctx->StartPerformanceTimer(PT_TOD_ACCESS); + StartPerformanceTimer(PT_TOD_ACCESS); bool ageTimePropogated = false; @@ -135,7 +135,7 @@ static bool UpdateToDAccess(Entrance* entrance, bool propagateTimeTravel) { AreaTable(RR_ROOT)->childNight = AreaTable(RR_TOT_BEYOND_DOOR_OF_TIME)->adultNight; } - ctx->StopPerformanceTimer(PT_TOD_ACCESS); + StopPerformanceTimer(PT_TOD_ACCESS); return ageTimePropogated; } @@ -363,7 +363,7 @@ void AddToPlaythrough(LocationAccess& locPair, GetAccessableLocationsStruct& gal // Adds the contents of a location to the current progression and optionally playthrough bool AddCheckToLogic(LocationAccess& locPair, GetAccessableLocationsStruct& gals, RandomizerGet ignore, bool stopOnBeatable, bool addToPlaythrough=false){ auto ctx = Rando::Context::GetInstance(); - ctx->StartPerformanceTimer(PT_LOCATION_LOGIC); + StartPerformanceTimer(PT_LOCATION_LOGIC); RandomizerCheck loc = locPair.GetLocation(); Rando::ItemLocation* location = ctx->GetItemLocation(loc); RandomizerGet locItem = location->GetPlacedRandomizerGet(); @@ -403,11 +403,11 @@ bool AddCheckToLogic(LocationAccess& locPair, GetAccessableLocationsStruct& gals } //All we care about is if the game is beatable, used to pare down playthrough if (location->GetPlacedRandomizerGet() == RG_TRIFORCE && stopOnBeatable) { - ctx->StopPerformanceTimer(PT_LOCATION_LOGIC); + StopPerformanceTimer(PT_LOCATION_LOGIC); return true; //Return early for efficiency } } - ctx->StopPerformanceTimer(PT_LOCATION_LOGIC); + StopPerformanceTimer(PT_LOCATION_LOGIC); return false; } @@ -1155,7 +1155,7 @@ int Fill() { //Temporarily add shop items to the ItemPool so that entrance randomization //can validate the world using deku/hylian shields - ctx->StartPerformanceTimer(PT_ENTRANCE_SHUFFLE); + StartPerformanceTimer(PT_ENTRANCE_SHUFFLE); AddElementsToPool(ItemPool, GetMinVanillaShopItems(32)); //assume worst case shopsanity 4 if (ctx->GetOption(RSK_SHUFFLE_ENTRANCES)) { SPDLOG_INFO("Shuffling Entrances..."); @@ -1169,12 +1169,12 @@ int Fill() { SetAreas(); //erase temporary shop items FilterAndEraseFromPool(ItemPool, [](const auto item) { return Rando::StaticData::RetrieveItem(item).GetItemType() == ITEMTYPE_SHOP; }); - ctx->StopPerformanceTimer(PT_ENTRANCE_SHUFFLE); + StopPerformanceTimer(PT_ENTRANCE_SHUFFLE); //ctx->showItemProgress = true; //Place shop items first, since a buy shield is needed to place a dungeon reward on Gohma due to access - ctx->StartPerformanceTimer(PT_SHOPSANITY); + StartPerformanceTimer(PT_SHOPSANITY); NonShopItems = {}; if (ctx->GetOption(RSK_SHOPSANITY).Is(RO_SHOPSANITY_OFF)) { SPDLOG_INFO("Placing Vanilla Shop Items..."); @@ -1221,9 +1221,9 @@ int Fill() { //Place the shop items which will still be at shop locations AssumedFill(shopItems, shopLocations); } - ctx->StopPerformanceTimer(PT_SHOPSANITY); + StopPerformanceTimer(PT_SHOPSANITY); - ctx->StartPerformanceTimer(PT_OWN_DUNGEON); + StartPerformanceTimer(PT_OWN_DUNGEON); //Place dungeon rewards SPDLOG_INFO("Shuffling and Placing Dungeon Items..."); RandomizeDungeonRewards(); @@ -1232,9 +1232,9 @@ int Fill() { for (auto dungeon : ctx->GetDungeons()->GetDungeonList()) { RandomizeOwnDungeon(dungeon); } - ctx->StopPerformanceTimer(PT_OWN_DUNGEON); + StopPerformanceTimer(PT_OWN_DUNGEON); - ctx->StartPerformanceTimer(PT_LIMITED_CHECKS); + StartPerformanceTimer(PT_LIMITED_CHECKS); //Then Place songs if song shuffle is set to specific locations if (ctx->GetOption(RSK_SHUFFLE_SONGS).IsNot(RO_SONG_SHUFFLE_ANYWHERE)) { @@ -1263,23 +1263,23 @@ int Fill() { //Then place Link's Pocket Item if it has to be an advancement item RandomizeLinksPocket(); - ctx->StopPerformanceTimer(PT_LIMITED_CHECKS); + StopPerformanceTimer(PT_LIMITED_CHECKS); - ctx->StartPerformanceTimer(PT_ADVANCEMENT_ITEMS); + StartPerformanceTimer(PT_ADVANCEMENT_ITEMS); SPDLOG_INFO("Shuffling Advancement Items"); //Then place the rest of the advancement items std::vector remainingAdvancementItems = FilterAndEraseFromPool(ItemPool, [](const auto i) { return Rando::StaticData::RetrieveItem(i).IsAdvancement(); }); AssumedFill(remainingAdvancementItems, ctx->allLocations, true); - ctx->StopPerformanceTimer(PT_ADVANCEMENT_ITEMS); + StopPerformanceTimer(PT_ADVANCEMENT_ITEMS); - ctx->StartPerformanceTimer(PT_REMAINING_ITEMS); + StartPerformanceTimer(PT_REMAINING_ITEMS); //Fast fill for the rest of the pool SPDLOG_INFO("Shuffling Remaining Items"); std::vector remainingPool = FilterAndEraseFromPool(ItemPool, [](const auto i) { return true; }); FastFill(remainingPool, GetAllEmptyLocations(), false); - ctx->StopPerformanceTimer(PT_REMAINING_ITEMS); + StopPerformanceTimer(PT_REMAINING_ITEMS); //Add default prices to scrubs for (size_t i = 0; i < Rando::StaticData::scrubLocations.size(); i++) { @@ -1305,35 +1305,35 @@ int Fill() { } } - ctx->StartPerformanceTimer(PT_PLAYTHROUGH_GENERATION); + StartPerformanceTimer(PT_PLAYTHROUGH_GENERATION); GeneratePlaythrough(); - ctx->StopPerformanceTimer(PT_PLAYTHROUGH_GENERATION); + StopPerformanceTimer(PT_PLAYTHROUGH_GENERATION); //Successful placement, produced beatable result if(ctx->playthroughBeatable && !placementFailure) { SPDLOG_INFO("Calculating Playthrough..."); - ctx->StartPerformanceTimer(PT_PARE_DOWN_PLAYTHROUGH); + StartPerformanceTimer(PT_PARE_DOWN_PLAYTHROUGH); PareDownPlaythrough(); - ctx->StopPerformanceTimer(PT_PARE_DOWN_PLAYTHROUGH); + StopPerformanceTimer(PT_PARE_DOWN_PLAYTHROUGH); - ctx->StartPerformanceTimer(PT_WOTH); + StartPerformanceTimer(PT_WOTH); CalculateWotH(); - ctx->StopPerformanceTimer(PT_WOTH); + StopPerformanceTimer(PT_WOTH); - ctx->StartPerformanceTimer(PT_FOOLISH); + StartPerformanceTimer(PT_FOOLISH); CalculateBarren(); - ctx->StopPerformanceTimer(PT_FOOLISH); + StopPerformanceTimer(PT_FOOLISH); SPDLOG_INFO("Calculating Playthrough Done"); - ctx->StartPerformanceTimer(PT_OVERRIDES); + StartPerformanceTimer(PT_OVERRIDES); ctx->CreateItemOverrides(); ctx->GetEntranceShuffler()->CreateEntranceOverrides(); - ctx->StopPerformanceTimer(PT_OVERRIDES); + StopPerformanceTimer(PT_OVERRIDES); - ctx->StartPerformanceTimer(PT_HINTS); + StartPerformanceTimer(PT_HINTS); CreateAllHints(); CreateWarpSongTexts(); - ctx->StopPerformanceTimer(PT_HINTS); + StopPerformanceTimer(PT_HINTS); return 1; } //Unsuccessful placement diff --git a/soh/soh/Enhancements/randomizer/3drando/location_access.cpp b/soh/soh/Enhancements/randomizer/3drando/location_access.cpp index 555abbd19a2..97b31e13045 100644 --- a/soh/soh/Enhancements/randomizer/3drando/location_access.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/location_access.cpp @@ -7,6 +7,7 @@ #include "spoiler_log.hpp" #include "../trial.h" #include "../entrance.h" +#include "../../debugger/performanceTimer.h" #include @@ -90,9 +91,8 @@ Area::Area(std::string regionName_, std::string scene_, RandomizerArea area, Area::~Area() = default; bool Area::UpdateEvents(bool haveTimeAccess) { - auto ctx = Rando::Context::GetInstance(); if (timePass && haveTimeAccess) { - ctx->StartPerformanceTimer(PT_TOD_ACCESS); + StartPerformanceTimer(PT_TOD_ACCESS); if (Child()) { childDay = true; childNight = true; @@ -105,11 +105,11 @@ bool Area::UpdateEvents(bool haveTimeAccess) { AreaTable(RR_ROOT)->adultDay = true; AreaTable(RR_ROOT)->adultNight = true; } - ctx->StopPerformanceTimer(PT_TOD_ACCESS); + StopPerformanceTimer(PT_TOD_ACCESS); } bool eventsUpdated = false; - ctx->StartPerformanceTimer(PT_EVENT_ACCESS); + StartPerformanceTimer(PT_EVENT_ACCESS); for (EventAccess& event : events) { //If the event has already happened, there's no reason to check it @@ -125,7 +125,7 @@ bool Area::UpdateEvents(bool haveTimeAccess) { eventsUpdated = true; } } - ctx->StopPerformanceTimer(PT_EVENT_ACCESS); + StopPerformanceTimer(PT_EVENT_ACCESS); return eventsUpdated; } diff --git a/soh/soh/Enhancements/randomizer/3drando/menu.cpp b/soh/soh/Enhancements/randomizer/3drando/menu.cpp index bcfbff7433d..ef878f5131d 100644 --- a/soh/soh/Enhancements/randomizer/3drando/menu.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/menu.cpp @@ -10,6 +10,7 @@ #include "randomizer.hpp" #include "spoiler_log.hpp" #include "location_access.hpp" +#include "../../debugger/performanceTimer.h" #include #include "../../randomizer/randomizerTypes.h" #include @@ -24,8 +25,8 @@ Rando::Option* currentSetting; bool GenerateRandomizer(std::set excludedLocations, std::set enabledTricks, std::string seedInput) { const auto ctx = Rando::Context::GetInstance(); - ctx->ResetTimers(); - ctx->StartPerformanceTimer(PT_WHOLE_SEED); + ResetPerformanceTimers(); + StartPerformanceTimer(PT_WHOLE_SEED); srand(time(NULL)); // if a blank seed was entered, make a random one @@ -68,27 +69,27 @@ bool GenerateRandomizer(std::set excludedLocations, std::setGetOption(RSK_KEYSANITY).RestoreDelayedOption(); } - ctx->StopPerformanceTimer(PT_WHOLE_SEED); - SPDLOG_DEBUG("Full Seed Genration Time: {}ms", ctx->GetPerformanceTimer(PT_WHOLE_SEED).count()); - SPDLOG_DEBUG("LogicReset time: {}ms", ctx->GetPerformanceTimer(PT_LOGIC_RESET).count()); - SPDLOG_DEBUG("Area->Reset time: {}ms", ctx->GetPerformanceTimer(PT_AREA_RESET).count()); - SPDLOG_DEBUG("Total Entrance Shuffle time: {}ms", ctx->GetPerformanceTimer(PT_ENTRANCE_SHUFFLE).count()); - SPDLOG_DEBUG("Total Shopsanity time: {}ms", ctx->GetPerformanceTimer(PT_SHOPSANITY).count()); - SPDLOG_DEBUG("Total Dungeon Specific Items time: {}ms", ctx->GetPerformanceTimer(PT_OWN_DUNGEON).count()); - SPDLOG_DEBUG("Total Misc Limited Checks time: {}ms", ctx->GetPerformanceTimer(PT_LIMITED_CHECKS).count()); - SPDLOG_DEBUG("Total Advancment Checks time: {}ms", ctx->GetPerformanceTimer(PT_ADVANCEMENT_ITEMS).count()); - SPDLOG_DEBUG("Total Other Checks time: {}ms", ctx->GetPerformanceTimer(PT_REMAINING_ITEMS).count()); - SPDLOG_DEBUG("Total Playthrough Generation time: {}ms", ctx->GetPerformanceTimer(PT_PLAYTHROUGH_GENERATION).count()); - SPDLOG_DEBUG("Total PareDownPlaythrough time: {}ms", ctx->GetPerformanceTimer(PT_PARE_DOWN_PLAYTHROUGH).count()); - SPDLOG_DEBUG("Total WotH generation time: {}ms", ctx->GetPerformanceTimer(PT_WOTH).count()); - SPDLOG_DEBUG("Total Foolish generation time: {}ms", ctx->GetPerformanceTimer(PT_FOOLISH).count()); - SPDLOG_DEBUG("Total Overrides time: {}ms", ctx->GetPerformanceTimer(PT_OVERRIDES).count()); - SPDLOG_DEBUG("Total Hint Generation time: {}ms", ctx->GetPerformanceTimer(PT_HINTS).count()); - SPDLOG_DEBUG("SpoilerLog writing time: {}ms", ctx->GetPerformanceTimer(PT_SPOILER_LOG).count()); - SPDLOG_DEBUG("Total UpdateHelpers time: {}ms", ctx->GetPerformanceTimer(PT_UPDATE_HELPERS).count()); - SPDLOG_DEBUG("Total Event Access Calculation time: {}ms", ctx->GetPerformanceTimer(PT_EVENT_ACCESS).count()); - SPDLOG_DEBUG("Total ToD Access Calculation: {}ms", ctx->GetPerformanceTimer(PT_TOD_ACCESS).count()); - SPDLOG_DEBUG("Total Entrance Logic Calculation time: {}ms", ctx->GetPerformanceTimer(PT_ENTRANCE_LOGIC).count()); - SPDLOG_DEBUG("Total Check Logic Calculation time: {}ms", ctx->GetPerformanceTimer(PT_LOCATION_LOGIC).count()); + StopPerformanceTimer(PT_WHOLE_SEED); + SPDLOG_DEBUG("Full Seed Genration Time: {}ms", GetPerformanceTimer(PT_WHOLE_SEED).count()); + SPDLOG_DEBUG("LogicReset time: {}ms", GetPerformanceTimer(PT_LOGIC_RESET).count()); + SPDLOG_DEBUG("Area->Reset time: {}ms", GetPerformanceTimer(PT_AREA_RESET).count()); + SPDLOG_DEBUG("Total Entrance Shuffle time: {}ms", GetPerformanceTimer(PT_ENTRANCE_SHUFFLE).count()); + SPDLOG_DEBUG("Total Shopsanity time: {}ms", GetPerformanceTimer(PT_SHOPSANITY).count()); + SPDLOG_DEBUG("Total Dungeon Specific Items time: {}ms", GetPerformanceTimer(PT_OWN_DUNGEON).count()); + SPDLOG_DEBUG("Total Misc Limited Checks time: {}ms", GetPerformanceTimer(PT_LIMITED_CHECKS).count()); + SPDLOG_DEBUG("Total Advancment Checks time: {}ms", GetPerformanceTimer(PT_ADVANCEMENT_ITEMS).count()); + SPDLOG_DEBUG("Total Other Checks time: {}ms", GetPerformanceTimer(PT_REMAINING_ITEMS).count()); + SPDLOG_DEBUG("Total Playthrough Generation time: {}ms", GetPerformanceTimer(PT_PLAYTHROUGH_GENERATION).count()); + SPDLOG_DEBUG("Total PareDownPlaythrough time: {}ms", GetPerformanceTimer(PT_PARE_DOWN_PLAYTHROUGH).count()); + SPDLOG_DEBUG("Total WotH generation time: {}ms", GetPerformanceTimer(PT_WOTH).count()); + SPDLOG_DEBUG("Total Foolish generation time: {}ms", GetPerformanceTimer(PT_FOOLISH).count()); + SPDLOG_DEBUG("Total Overrides time: {}ms", GetPerformanceTimer(PT_OVERRIDES).count()); + SPDLOG_DEBUG("Total Hint Generation time: {}ms", GetPerformanceTimer(PT_HINTS).count()); + SPDLOG_DEBUG("SpoilerLog writing time: {}ms", GetPerformanceTimer(PT_SPOILER_LOG).count()); + SPDLOG_DEBUG("Total UpdateHelpers time: {}ms", GetPerformanceTimer(PT_UPDATE_HELPERS).count()); + SPDLOG_DEBUG("Total Event Access Calculation time: {}ms", GetPerformanceTimer(PT_EVENT_ACCESS).count()); + SPDLOG_DEBUG("Total ToD Access Calculation: {}ms", GetPerformanceTimer(PT_TOD_ACCESS).count()); + SPDLOG_DEBUG("Total Entrance Logic Calculation time: {}ms", GetPerformanceTimer(PT_ENTRANCE_LOGIC).count()); + SPDLOG_DEBUG("Total Check Logic Calculation time: {}ms", GetPerformanceTimer(PT_LOCATION_LOGIC).count()); return true; } \ No newline at end of file diff --git a/soh/soh/Enhancements/randomizer/3drando/playthrough.cpp b/soh/soh/Enhancements/randomizer/3drando/playthrough.cpp index f77524bd0c5..fc7d7d2e0fa 100644 --- a/soh/soh/Enhancements/randomizer/3drando/playthrough.cpp +++ b/soh/soh/Enhancements/randomizer/3drando/playthrough.cpp @@ -11,6 +11,7 @@ #include "variables.h" #include "soh/OTRGlobals.h" #include "../option.h" +#include "../../debugger/performanceTimer.h" namespace Playthrough { @@ -25,9 +26,9 @@ int Playthrough_Init(uint32_t seed, std::set excludedLocations, ctx->ItemReset(); ctx->HintReset(); ctx->GetLogic()->Reset(); - ctx->StartPerformanceTimer(PT_AREA_RESET); + StartPerformanceTimer(PT_AREA_RESET); Areas::AccessReset(); - ctx->StopPerformanceTimer(PT_AREA_RESET); + StopPerformanceTimer(PT_AREA_RESET); ctx->GetSettings()->FinalizeSettings(excludedLocations, enabledTricks); // once the settings have been finalized turn them into a string for hashing @@ -73,13 +74,13 @@ int Playthrough_Init(uint32_t seed, std::set excludedLocations, //TODO: Handle different types of file output (i.e. Spoiler Log, Plando Template, Patch Files, Race Files, etc.) // write logs SPDLOG_INFO("Writing Spoiler Log..."); - ctx->StartPerformanceTimer(PT_SPOILER_LOG); + StartPerformanceTimer(PT_SPOILER_LOG); if (SpoilerLog_Write()) { SPDLOG_INFO("Writing Spoiler Log Done"); } else { SPDLOG_ERROR("Writing Spoiler Log Failed"); } - ctx->StopPerformanceTimer(PT_SPOILER_LOG); + StopPerformanceTimer(PT_SPOILER_LOG); #ifdef ENABLE_DEBUG SPDLOG_INFO("Writing Placement Log..."); if (PlacementLog_Write()) { diff --git a/soh/soh/Enhancements/randomizer/context.cpp b/soh/soh/Enhancements/randomizer/context.cpp index 730d2dae5de..8f1ea557f4c 100644 --- a/soh/soh/Enhancements/randomizer/context.cpp +++ b/soh/soh/Enhancements/randomizer/context.cpp @@ -1222,20 +1222,4 @@ void Context::SetAmmo(uint32_t item, uint8_t count) { mSaveContext->inventory.ammo[gItemSlots[item]] = count; } -void Context::StartPerformanceTimer(PerformanceTimers timer){ - timeStarted[timer] = std::chrono::high_resolution_clock::now(); -} - -void Context::StopPerformanceTimer(PerformanceTimers timer){ - totalTimes[timer] += (std::chrono::high_resolution_clock::now() - timeStarted[timer]); -} - -std::chrono::duration Context::GetPerformanceTimer(PerformanceTimers timer){ - return totalTimes[timer]; -} - -void Context::ResetTimers(){ - totalTimes = {}; -} - } // namespace Rando diff --git a/soh/soh/Enhancements/randomizer/context.h b/soh/soh/Enhancements/randomizer/context.h index 69ddbf50005..50800363c22 100644 --- a/soh/soh/Enhancements/randomizer/context.h +++ b/soh/soh/Enhancements/randomizer/context.h @@ -123,10 +123,6 @@ class Context { void SetEventChkInf(int32_t flag, bool state); uint8_t GetAmmo(uint32_t item); void SetAmmo(uint32_t item, uint8_t count); - void StartPerformanceTimer(PerformanceTimers timer); - void StopPerformanceTimer(PerformanceTimers timer); - std::chrono::duration GetPerformanceTimer(PerformanceTimers timer); - void ResetTimers(); private: @@ -143,7 +139,5 @@ class Context { bool mSeedGenerated = false; bool mSpoilerLoaded = false; bool mPlandoLoaded = false; - std::array, PT_MAX> totalTimes = {}; - std::array timeStarted = {}; }; } // namespace Rando \ No newline at end of file diff --git a/soh/soh/Enhancements/randomizer/entrance.cpp b/soh/soh/Enhancements/randomizer/entrance.cpp index 110c929c7ca..8610734b9ce 100644 --- a/soh/soh/Enhancements/randomizer/entrance.cpp +++ b/soh/soh/Enhancements/randomizer/entrance.cpp @@ -2,6 +2,7 @@ #include "3drando/pool_functions.hpp" #include "3drando/item_pool.hpp" +#include "../debugger/performanceTimer.h" #include @@ -71,12 +72,12 @@ void Entrance::printAgeTimeAccess() { bool Entrance::ConditionsMet(bool allAgeTimes) const { auto ctx = Rando::Context::GetInstance(); - ctx->StartPerformanceTimer(PT_ENTRANCE_LOGIC); + StartPerformanceTimer(PT_ENTRANCE_LOGIC); Area* parent = AreaTable(parentRegion); int conditionsMet = 0; if (allAgeTimes && !parent->AllAccess()) { - ctx->StopPerformanceTimer(PT_ENTRANCE_LOGIC); + StopPerformanceTimer(PT_ENTRANCE_LOGIC); return false; } @@ -86,7 +87,7 @@ bool Entrance::ConditionsMet(bool allAgeTimes) const { (parent->adultDay && CheckConditionAtAgeTime(logic->IsAdult, logic->AtDay, allAgeTimes)) + (parent->adultNight && CheckConditionAtAgeTime(logic->IsAdult, logic->AtNight, allAgeTimes)); - ctx->StopPerformanceTimer(PT_ENTRANCE_LOGIC); + StopPerformanceTimer(PT_ENTRANCE_LOGIC); return conditionsMet && (!allAgeTimes || conditionsMet == 4); } diff --git a/soh/soh/Enhancements/randomizer/logic.cpp b/soh/soh/Enhancements/randomizer/logic.cpp index 3fabfcde345..ba831183291 100644 --- a/soh/soh/Enhancements/randomizer/logic.cpp +++ b/soh/soh/Enhancements/randomizer/logic.cpp @@ -1,4 +1,5 @@ #include "logic.h" +#include "../debugger/performanceTimer.h" #include #include @@ -455,7 +456,7 @@ namespace Rando { // Updates all logic helpers. Should be called whenever a non-helper is changed void Logic::UpdateHelpers() { - ctx->StartPerformanceTimer(PT_UPDATE_HELPERS); + StartPerformanceTimer(PT_UPDATE_HELPERS); OcarinaButtons = (HasItem(RG_OCARINA_A_BUTTON) ? 1 : 0) + (HasItem(RG_OCARINA_C_LEFT_BUTTON) ? 1 : 0) + (HasItem(RG_OCARINA_C_RIGHT_BUTTON) ? 1 : 0) + @@ -660,7 +661,7 @@ namespace Rando { (ctx->GetSettings()->LACSCondition() == RO_LACS_DUNGEONS && DungeonCount + (Greg && GregInLacsLogic ? 1 : 0) >= ctx->GetOption(RSK_LACS_DUNGEON_COUNT).Value()) || (ctx->GetSettings()->LACSCondition() == RO_LACS_TOKENS && GoldSkulltulaTokens >= ctx->GetOption(RSK_LACS_TOKEN_COUNT).Value()); CanCompleteTriforce = TriforcePieces >= ctx->GetOption(RSK_TRIFORCE_HUNT_PIECES_REQUIRED).Value(); - ctx->StopPerformanceTimer(PT_UPDATE_HELPERS); + StopPerformanceTimer(PT_UPDATE_HELPERS); } bool Logic::SmallKeys(RandomizerRegion dungeon, uint8_t requiredAmount) { @@ -778,7 +779,7 @@ namespace Rando { void Logic::Reset() { ctx->NewSaveContext(); - ctx->StartPerformanceTimer(PT_LOGIC_RESET); + StartPerformanceTimer(PT_LOGIC_RESET); memset(inLogic, false, sizeof(inLogic)); //Settings-dependent variables IsKeysanity = ctx->GetOption(RSK_KEYSANITY).Is(RO_DUNGEON_ITEM_LOC_ANYWHERE) || @@ -1120,6 +1121,6 @@ namespace Rando { BuyDekuShieldPast = false; TimeTravelPast = false; - ctx->StopPerformanceTimer(PT_LOGIC_RESET); + StopPerformanceTimer(PT_LOGIC_RESET); } } diff --git a/soh/soh/Enhancements/randomizer/randomizerTypes.h b/soh/soh/Enhancements/randomizer/randomizerTypes.h index 753cbc2a09d..304fef213cd 100644 --- a/soh/soh/Enhancements/randomizer/randomizerTypes.h +++ b/soh/soh/Enhancements/randomizer/randomizerTypes.h @@ -4324,29 +4324,4 @@ typedef enum { TH_MESSAGE_SURPLUS, } TriforceHuntMessages; -typedef enum { - PT_WHOLE_SEED, - PT_LOGIC_RESET, - PT_AREA_RESET, - PT_UPDATE_HELPERS, - PT_SPOILER_LOG, - PT_ENTRANCE_SHUFFLE, - PT_SHOPSANITY, - PT_OWN_DUNGEON, - PT_LIMITED_CHECKS, - PT_ADVANCEMENT_ITEMS, - PT_REMAINING_ITEMS, - PT_PLAYTHROUGH_GENERATION, - PT_PARE_DOWN_PLAYTHROUGH, - PT_WOTH, - PT_FOOLISH, - PT_OVERRIDES, - PT_HINTS, - PT_EVENT_ACCESS, - PT_TOD_ACCESS, - PT_ENTRANCE_LOGIC, - PT_LOCATION_LOGIC, - PT_MAX -} PerformanceTimers; - From 0f9925b4a6c7eb41789221686a622d1f2ee7aeea Mon Sep 17 00:00:00 2001 From: Pepper0ni <93387759+Pepper0ni@users.noreply.github.com> Date: Sat, 21 Sep 2024 19:16:23 +0100 Subject: [PATCH 8/8] forgot to add files --- .../debugger/performanceTimer.cpp | 19 ++++++++++ .../Enhancements/debugger/performanceTimer.h | 38 +++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 soh/soh/Enhancements/debugger/performanceTimer.cpp create mode 100644 soh/soh/Enhancements/debugger/performanceTimer.h diff --git a/soh/soh/Enhancements/debugger/performanceTimer.cpp b/soh/soh/Enhancements/debugger/performanceTimer.cpp new file mode 100644 index 00000000000..f52a8efaca0 --- /dev/null +++ b/soh/soh/Enhancements/debugger/performanceTimer.cpp @@ -0,0 +1,19 @@ +#pragma once + +#include "performanceTimer.h" + +void StartPerformanceTimer(TimerID timer){ + timeStarted[timer] = std::chrono::high_resolution_clock::now(); +} + +void StopPerformanceTimer(TimerID timer){ + totalTimes[timer] += (std::chrono::high_resolution_clock::now() - timeStarted[timer]); +} + +std::chrono::duration GetPerformanceTimer(TimerID timer){ + return totalTimes[timer]; +} + +void ResetPerformanceTimers(){ + totalTimes = {}; +} \ No newline at end of file diff --git a/soh/soh/Enhancements/debugger/performanceTimer.h b/soh/soh/Enhancements/debugger/performanceTimer.h new file mode 100644 index 00000000000..ed7626326e5 --- /dev/null +++ b/soh/soh/Enhancements/debugger/performanceTimer.h @@ -0,0 +1,38 @@ +#pragma once + +#include +#include +#include + +typedef enum { + PT_WHOLE_SEED, + PT_LOGIC_RESET, + PT_AREA_RESET, + PT_UPDATE_HELPERS, + PT_SPOILER_LOG, + PT_ENTRANCE_SHUFFLE, + PT_SHOPSANITY, + PT_OWN_DUNGEON, + PT_LIMITED_CHECKS, + PT_ADVANCEMENT_ITEMS, + PT_REMAINING_ITEMS, + PT_PLAYTHROUGH_GENERATION, + PT_PARE_DOWN_PLAYTHROUGH, + PT_WOTH, + PT_FOOLISH, + PT_OVERRIDES, + PT_HINTS, + PT_EVENT_ACCESS, + PT_TOD_ACCESS, + PT_ENTRANCE_LOGIC, + PT_LOCATION_LOGIC, + PT_MAX +} TimerID; + +void StartPerformanceTimer(TimerID timer); +void StopPerformanceTimer(TimerID timer); +std::chrono::duration GetPerformanceTimer(TimerID timer); +void ResetPerformanceTimers(); +static std::array, PT_MAX> totalTimes = {}; +static std::array timeStarted = {}; +