2016-04-21 00:53:38 +00:00
|
|
|
|
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
|
|
|
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
using Microsoft.DotNet.Cli.Utils;
|
2016-08-09 18:05:00 +00:00
|
|
|
|
using Microsoft.DotNet.PlatformAbstractions;
|
2016-04-21 00:53:38 +00:00
|
|
|
|
|
|
|
|
|
namespace Microsoft.DotNet.Cli
|
|
|
|
|
{
|
|
|
|
|
internal class MulticoreJitProfilePathCalculator
|
|
|
|
|
{
|
|
|
|
|
private string _multicoreJitProfilePath;
|
|
|
|
|
|
|
|
|
|
public string MulticoreJitProfilePath
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (_multicoreJitProfilePath == null)
|
|
|
|
|
{
|
|
|
|
|
CalculateProfileRootPath();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return _multicoreJitProfilePath;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void CalculateProfileRootPath()
|
|
|
|
|
{
|
2016-04-25 18:22:32 +00:00
|
|
|
|
var profileRoot = GetRuntimeDataRootPathString();
|
2016-04-21 00:53:38 +00:00
|
|
|
|
|
|
|
|
|
var version = Product.Version;
|
|
|
|
|
|
2016-06-08 23:28:52 +00:00
|
|
|
|
var rid = RuntimeEnvironment.GetRuntimeIdentifier();
|
2016-04-21 00:53:38 +00:00
|
|
|
|
|
2016-05-26 03:41:10 +00:00
|
|
|
|
_multicoreJitProfilePath = Path.Combine(profileRoot, "optimizationdata", version, rid);
|
2016-04-21 00:53:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-04-25 18:22:32 +00:00
|
|
|
|
private string GetRuntimeDataRootPathString()
|
2016-04-21 00:53:38 +00:00
|
|
|
|
{
|
|
|
|
|
return RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
|
|
|
|
|
? GetWindowsRuntimeDataRoot()
|
|
|
|
|
: GetNonWindowsRuntimeDataRoot();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static string GetWindowsRuntimeDataRoot()
|
|
|
|
|
{
|
|
|
|
|
return $@"{(Environment.GetEnvironmentVariable("LocalAppData"))}\Microsoft\dotnet\";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static string GetNonWindowsRuntimeDataRoot()
|
|
|
|
|
{
|
|
|
|
|
return $"{(Environment.GetEnvironmentVariable("HOME"))}/.dotnet/";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|