-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
executable file
·53 lines (52 loc) · 1.6 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
namespace kill_ryzen_win
{
class Program
{
static void Main(string[] args)
{
var compiler = "cl";
int? jobs = null;
for (var i = 0; i < args.Length; ++i)
{
switch (args[i])
{
case "-c": compiler = args[++i]; break;
case "-j": jobs = int.Parse(args[++i]); break;
}
}
if (jobs.HasValue)
{
int a, b;
System.Threading.ThreadPool.GetMinThreads(out a, out b);
System.Threading.ThreadPool.SetMinThreads(jobs.Value, b);
}
Parallel.For(0, int.MaxValue, x =>
{
var tmp = Path.GetTempFileName();
try
{
// extra quotes due to weird cmd.exe /c quoting rules, see cmd.exe /?
var psi = new ProcessStartInfo("cmd.exe", $"/q/c \"\"{compiler}\" /nologo /c bzip2.c /Fo\"{tmp}\" || exit /b\"")
{
UseShellExecute = false,
};
using (var p = Process.Start(psi))
{
p.WaitForExit();
if (p.ExitCode != 0)
throw new Exception("FAIL");
}
}
finally
{
File.Delete(tmp);
}
});
}
}
}