mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2025-12-20 08:18:37 +00:00
Add hacked optimization mode
This commit is contained in:
@@ -354,6 +354,7 @@
|
|||||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=EWCF/@EntryIndexedValue">EWCF</s:String>
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=EWCF/@EntryIndexedValue">EWCF</s:String>
|
||||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=FA/@EntryIndexedValue">FA</s:String>
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=FA/@EntryIndexedValue">FA</s:String>
|
||||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=FS/@EntryIndexedValue">FS</s:String>
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=FS/@EntryIndexedValue">FS</s:String>
|
||||||
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=GC/@EntryIndexedValue">GC</s:String>
|
||||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=HTML/@EntryIndexedValue">HTML</s:String>
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=HTML/@EntryIndexedValue">HTML</s:String>
|
||||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=ID/@EntryIndexedValue">ID</s:String>
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=ID/@EntryIndexedValue">ID</s:String>
|
||||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=IP/@EntryIndexedValue">IP</s:String>
|
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=IP/@EntryIndexedValue">IP</s:String>
|
||||||
|
|||||||
@@ -182,7 +182,8 @@ namespace ArchiSteamFarm {
|
|||||||
|
|
||||||
internal enum EOptimizationMode : byte {
|
internal enum EOptimizationMode : byte {
|
||||||
MaxPerformance,
|
MaxPerformance,
|
||||||
MinMemoryUsage
|
MinMemoryUsage,
|
||||||
|
MaxPerformanceWithPeriodicalGC = 255 // Hack, don't depend on this
|
||||||
}
|
}
|
||||||
|
|
||||||
[SuppressMessage("ReSharper", "UnusedMember.Global")]
|
[SuppressMessage("ReSharper", "UnusedMember.Global")]
|
||||||
|
|||||||
56
ArchiSteamFarm/Hacks.cs
Normal file
56
ArchiSteamFarm/Hacks.cs
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
_ _ _ ____ _ _____
|
||||||
|
/ \ _ __ ___ | |__ (_)/ ___| | |_ ___ __ _ _ __ ___ | ___|__ _ _ __ _ __ ___
|
||||||
|
/ _ \ | '__|/ __|| '_ \ | |\___ \ | __|/ _ \ / _` || '_ ` _ \ | |_ / _` || '__|| '_ ` _ \
|
||||||
|
/ ___ \ | | | (__ | | | || | ___) || |_| __/| (_| || | | | | || _|| (_| || | | | | | | |
|
||||||
|
/_/ \_\|_| \___||_| |_||_||____/ \__|\___| \__,_||_| |_| |_||_| \__,_||_| |_| |_| |_|
|
||||||
|
|
||||||
|
Copyright 2015-2017 Łukasz "JustArchi" Domeradzki
|
||||||
|
Contact: JustArchi@JustArchi.net
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Runtime;
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
|
namespace ArchiSteamFarm {
|
||||||
|
internal static class Hacks {
|
||||||
|
private const byte GarbageCollectorDelay = 1;
|
||||||
|
|
||||||
|
private static Timer GarbageCollectionTimer;
|
||||||
|
private static Timer GarbageCompactionTimer;
|
||||||
|
|
||||||
|
internal static void Init() {
|
||||||
|
if (GarbageCollectionTimer == null) {
|
||||||
|
GarbageCollectionTimer = new Timer(
|
||||||
|
e => GC.Collect(),
|
||||||
|
null,
|
||||||
|
TimeSpan.FromSeconds(GarbageCollectorDelay), // Delay
|
||||||
|
TimeSpan.FromSeconds(GarbageCollectorDelay) // Period
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GarbageCompactionTimer == null) {
|
||||||
|
GarbageCompactionTimer = new Timer(
|
||||||
|
e => GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce,
|
||||||
|
null,
|
||||||
|
TimeSpan.FromMinutes(GarbageCollectorDelay), // Delay
|
||||||
|
TimeSpan.FromMinutes(GarbageCollectorDelay) // Period
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -232,6 +232,10 @@ namespace ArchiSteamFarm {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (GlobalConfig.OptimizationMode == GlobalConfig.EOptimizationMode.MaxPerformanceWithPeriodicalGC) {
|
||||||
|
Hacks.Init();
|
||||||
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(GlobalConfig.CurrentCulture)) {
|
if (!string.IsNullOrEmpty(GlobalConfig.CurrentCulture)) {
|
||||||
try {
|
try {
|
||||||
// GetCultureInfo() would be better but we can't use it for specifying neutral cultures such as "en"
|
// GetCultureInfo() would be better but we can't use it for specifying neutral cultures such as "en"
|
||||||
|
|||||||
Reference in New Issue
Block a user