-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve eval times by moving "EvalProgram" to its own project
Before, "EvalProgram" was compiled and injected into the running game by running MSBuild on the "Eval" target. This took a couple of seconds. Now, "EvalProgram" is in its own project. Compilation and injection into the running game is done by building the "Eval" project in Visual Studio. It takes maybe a second. The performance improvement seems to come from compilation via Visual Studio's UI being faster than compilation via invoking MSBuild.exe.
- Loading branch information
Showing
9 changed files
with
255 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- This file contains project properties used by the build. --> | ||
<Project> | ||
<PropertyGroup> | ||
<ImportBSMTTargets>True</ImportBSMTTargets> | ||
<BSMTProjectType>BSIPA</BSMTProjectType> | ||
</PropertyGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProductVersion>8.0.30703</ProductVersion> | ||
<SchemaVersion>2.0</SchemaVersion> | ||
<ProjectGuid>{AD941956-A7E0-4DF6-896A-2171FA294784}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>Eval</RootNamespace> | ||
<AssemblyName>Eval</AssemblyName> | ||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>portable</DebugType> | ||
<LocalRefsDir Condition="Exists('..\Refs')">..\Refs</LocalRefsDir> | ||
<BeatSaberDir>$(LocalRefsDir)</BeatSaberDir> | ||
<AppOutputBase>$(MSBuildProjectDirectory)\</AppOutputBase> | ||
<!--<PathMap>$(AppOutputBase)=X:\$(AssemblyName)\</PathMap>--> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="$(DefineConstants.Contains('CIBuild')) OR '$(NCrunch)' == '1'"> | ||
<DisableCopyToPlugins>True</DisableCopyToPlugins> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(NCrunch)' == '1'"> | ||
<DisableCopyToPlugins>True</DisableCopyToPlugins> | ||
<DisableZipRelease>True</DisableZipRelease> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<!-- | ||
Disable various Beat Saber Modding Tools features that aren't needed for | ||
the "Eval" project. Perhaps the modding tools aren't needed at all. The | ||
main feature I'm interested in is the "Beat Saber Reference Manager" so | ||
the project can reference Beat Saber's dependencies and other Beat Saber | ||
plugins. | ||
--> | ||
<DisableCopyToGame>True</DisableCopyToGame> | ||
<DisableCopyToPlugins>True</DisableCopyToPlugins> | ||
<DisableZipRelease>True</DisableZipRelease> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="BeatmapCore"> | ||
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\BeatmapCore.dll</HintPath> | ||
<Private>False</Private> | ||
<SpecificVersion>False</SpecificVersion> | ||
</Reference> | ||
<Reference Include="InfiniteBeatSaber"> | ||
<HintPath>$(BeatSaberDir)\Plugins\InfiniteBeatSaber.dll</HintPath> | ||
<Private>False</Private> | ||
<SpecificVersion>False</SpecificVersion> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Xml" /> | ||
<Reference Include="Main"> | ||
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\Main.dll</HintPath> | ||
<Private>False</Private> | ||
</Reference> | ||
<Reference Include="HMLib"> | ||
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\HMLib.dll</HintPath> | ||
<Private>False</Private> | ||
</Reference> | ||
<Reference Include="HMUI"> | ||
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\HMUI.dll</HintPath> | ||
<Private>False</Private> | ||
</Reference> | ||
<Reference Include="IPA.Loader"> | ||
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\IPA.Loader.dll</HintPath> | ||
<Private>False</Private> | ||
</Reference> | ||
<Reference Include="Unity.TextMeshPro"> | ||
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\Unity.TextMeshPro.dll</HintPath> | ||
<Private>False</Private> | ||
</Reference> | ||
<Reference Include="UnityEngine"> | ||
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.dll</HintPath> | ||
<Private>False</Private> | ||
</Reference> | ||
<Reference Include="UnityEngine.CoreModule"> | ||
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.CoreModule.dll</HintPath> | ||
<Private>False</Private> | ||
</Reference> | ||
<Reference Include="UnityEngine.UI"> | ||
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.UI.dll</HintPath> | ||
<Private>False</Private> | ||
</Reference> | ||
<Reference Include="UnityEngine.UIElementsModule"> | ||
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.UIElementsModule.dll</HintPath> | ||
<Private>False</Private> | ||
</Reference> | ||
<Reference Include="UnityEngine.UIModule"> | ||
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.UIModule.dll</HintPath> | ||
<Private>False</Private> | ||
</Reference> | ||
<Reference Include="UnityEngine.VRModule"> | ||
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\UnityEngine.VRModule.dll</HintPath> | ||
<Private>False</Private> | ||
</Reference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="EvalProgram.cs" /> | ||
<Compile Include="Plugin.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<EmbeddedResource Include="manifest.json" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="Directory.Build.props" Condition="Exists('Directory.Build.props')" /> | ||
<None Include="Eval.csproj.user" Condition="Exists('Eval.csproj.user')" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<PackageReference Include="BeatSaberModdingTools.Tasks"> | ||
<Version>2.0.0-beta1</Version> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<!-- | ||
In this project, the intention of the "build" command is actually "eval the | ||
code in the game". | ||
A problematic case is that, if the source files are unchanged, then the | ||
"build" command will be a no-op. No code will be evaled in the game which | ||
violates the user's expectation. This is because both the "Build" and "Eval" | ||
targets will be skipped. | ||
"TouchSource", a pre-build target, is the workaround. It touches the source | ||
file, making it look dirty, and consequently forcing the "Build" and "Eval" | ||
targets to run. | ||
--> | ||
<Target Name="TouchSource" BeforeTargets="Build"> | ||
<Exec Command="powershell (Get-Item $(ProjectDir)EvalProgram.cs).LastWriteTime = Get-Date" /> | ||
</Target> | ||
<Target Name="Eval" AfterTargets="Build"> | ||
<Exec Command="powershell.exe -ExecutionPolicy Bypass -File "$(SolutionDir)debug-tools\repl\eval.ps1" -dllPath "$(TargetPath)"" /> | ||
</Target> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using IPA; | ||
using IPALogger = IPA.Logging.Logger; | ||
|
||
namespace Eval | ||
{ | ||
[Plugin(RuntimeOptions.SingleStartInit)] | ||
public class Plugin | ||
{ | ||
internal static Plugin Instance { get; private set; } | ||
/// <summary> | ||
/// Use to send log messages through BSIPA. | ||
/// </summary> | ||
internal static IPALogger Log { get; private set; } | ||
|
||
[Init] | ||
public Plugin(IPALogger logger) | ||
{ | ||
Instance = this; | ||
Log = logger; | ||
} | ||
|
||
[OnStart] | ||
public void OnApplicationStart() | ||
{ | ||
Plugin.Log.Info("OnApplicationStart"); | ||
} | ||
|
||
[OnExit] | ||
public void OnApplicationQuit() | ||
{ | ||
|
||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("Eval")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("HP")] | ||
[assembly: AssemblyProduct("Eval")] | ||
[assembly: AssemblyCopyright("Copyright © HP 2023")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("406a47c5-25bf-4c86-8f2c-4cba825b2052")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// You can specify all the values or you can default the Build and Revision Numbers | ||
// by using the '*' as shown below: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("0.0.1")] | ||
[assembly: AssemblyFileVersion("0.0.1")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"$schema": "https://raw.githubusercontent.com/bsmg/BSIPA-MetadataFileSchema/master/Schema.json", | ||
"id": "Eval", | ||
"name": "Eval", | ||
"author": "", | ||
"version": "0.0.1", | ||
"description": "", | ||
"gameVersion": "1.31.1", | ||
"dependsOn": { | ||
"BSIPA": "^4.2.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.