void CommandLineArgs::SetupOutputDirectories()

in Tools/WinMLRunner/src/CommandLineArgs.cpp [457:516]


void CommandLineArgs::SetupOutputDirectories(const std::wstring& sBaseOutputPath, const std::wstring& sPerfOutputPath,
                                             const std::wstring& sPerIterationDataPath)
{
    std::filesystem::path PerfOutputPath(sPerfOutputPath);
    std::filesystem::path BaseOutputPath(sBaseOutputPath);
    std::filesystem::path PerIterationDataPath(sPerIterationDataPath);

    if (PerfOutputPath.is_absolute())
    {
        m_perfOutputPath = PerfOutputPath.c_str();
        if (BaseOutputPath.empty())
        {
            BaseOutputPath = PerfOutputPath.remove_filename();
        }
    }

    if (PerIterationDataPath.is_absolute())
    {
        m_perIterationDataPath = PerIterationDataPath.c_str();
        if (BaseOutputPath.empty())
        {
            BaseOutputPath = PerIterationDataPath;
        }
    }

    if (m_perfOutputPath.empty() || m_perIterationDataPath.empty())
    {
        auto time = std::time(nullptr);
        struct tm localTime;
        localtime_s(&localTime, &time);
        std::wostringstream oss;
        oss << std::put_time(&localTime, L"%Y-%m-%d_%H.%M.%S");

        if (BaseOutputPath.empty())
        {
            BaseOutputPath = std::filesystem::current_path();
        }

        if (m_perfOutputPath.empty())
        {
            if (sPerfOutputPath.empty())
#ifdef USE_WINML_NUGET
                PerfOutputPath = L"MicrosoftMLRunner[" + oss.str() + L"].csv";
#else
                PerfOutputPath = L"WinMLRunner[" + oss.str() + L"].csv";
#endif
            PerfOutputPath = BaseOutputPath / PerfOutputPath;
            m_perfOutputPath = PerfOutputPath.c_str();
        }

        if (m_perIterationDataPath.empty())
        {
            if (sPerIterationDataPath.empty())
                PerIterationDataPath = L"PerIterationRun[" + oss.str() + L"]";

            PerIterationDataPath = BaseOutputPath / PerIterationDataPath;
            m_perIterationDataPath = PerIterationDataPath.c_str();
        }
    }
}