Новый раздел надо протестить Сидел учил как эту память туда сюда управлять по гайдам ютуба поддержкой друга и чата гпт Типо интерфейс хотел написать потно было но сойдет Картинки code using System; using System.Collections.Generic; using System.Drawing; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; namespace StressTester { public partial class Form1 : Form { private Thread? cpuThread; private Thread? ramThread; private bool cpuRunning = false; private bool ramRunning = false; private DateTime cpuStartTime; private DateTime ramStartTime; private Label cpuTimeLabel; private Label ramTimeLabel; private Button cpuButton; private Button ramButton; private System.Windows.Forms.Timer uiTimer; public Form1() { InitializeComponent(); this.Text = "Stress Tester"; this.Size = new Size(400, 250); this.BackColor = Color.FromArgb(240, 240, 240); cpuButton = new Button() { Text = "Start CPU Load", Location = new Point(20, 20), Size = new Size(150, 40) }; cpuButton.Click += CpuButton_Click; cpuButton.BackColor = Color.LightSteelBlue; cpuButton.FlatStyle = FlatStyle.Flat; this.Controls.Add(cpuButton); cpuTimeLabel = new Label() { Text = "CPU Time: 00:00:00.000", Location = new Point(200, 30), AutoSize = true, ForeColor = Color.DarkBlue, Font = new Font("Segoe UI", 10, FontStyle.Bold) }; this.Controls.Add(cpuTimeLabel); ramButton = new Button() { Text = "Start RAM Load", Location = new Point(20, 80), Size = new Size(150, 40) }; ramButton.Click += RamButton_Click; ramButton.BackColor = Color.LightCoral; ramButton.FlatStyle = FlatStyle.Flat; this.Controls.Add(ramButton); ramTimeLabel = new Label() { Text = "RAM Time: 00:00:00.000", Location = new Point(200, 90), AutoSize = true, ForeColor = Color.DarkRed, Font = new Font("Segoe UI", 10, FontStyle.Bold) }; this.Controls.Add(ramTimeLabel); uiTimer = new System.Windows.Forms.Timer(); uiTimer.Interval = 50; uiTimer.Tick += UiTimer_Tick; uiTimer.Start(); } private void CpuButton_Click(object? sender, EventArgs e) { if (!cpuRunning) { cpuRunning = true; cpuStartTime = DateTime.Now; cpuButton.Text = "Stop CPU Load"; cpuButton.BackColor = Color.LightGreen; cpuThread = new Thread(() => { while (cpuRunning) { Parallel.For(0, Environment.ProcessorCount * 2, _ => { while (cpuRunning) { double x = Math.Pow(new Random().NextDouble(), 3.14); } }); } }); cpuThread.IsBackground = true; cpuThread.Start(); } else { cpuRunning = false; cpuButton.Text = "Start CPU Load"; cpuButton.BackColor = Color.LightSteelBlue; cpuThread?.Join(); } } private void RamButton_Click(object? sender, EventArgs e) { if (!ramRunning) { ramRunning = true; ramStartTime = DateTime.Now; ramButton.Text = "Stop RAM Load"; ramButton.BackColor = Color.LightGreen; ramThread = new Thread(() => { var list = new List<byte[]>(); try { while (ramRunning) { var block = new byte[1000 * 1024 * 1024]; // 1000 MB for (int i = 0; i < block.Length; i += 4096) { block[i] = 1; } list.Add(block); Thread.Sleep(100); } } catch (OutOfMemoryException) { } }); ramThread.IsBackground = true; ramThread.Start(); } else { ramRunning = false; ramButton.Text = "Start RAM Load"; ramButton.BackColor = Color.LightCoral; ramThread?.Join(); } } private void UiTimer_Tick(object? sender, EventArgs e) { if (cpuRunning) { TimeSpan elapsed = DateTime.Now - cpuStartTime; cpuTimeLabel.Text = $"CPU Time: {elapsed:**\\:mm\\:ss\\.fff}"; } else { cpuTimeLabel.Text = "CPU Time: 00:00:00.000"; } if (ramRunning) { TimeSpan elapsed = DateTime.Now - ramStartTime; ramTimeLabel.Text = $"RAM Time: {elapsed:**\\:mm\\:ss\\.fff}"; } else { ramTimeLabel.Text = "RAM Time: 00:00:00.000"; } } protected override void OnFormClosing(FormClosingEventArgs e) { cpuRunning = false; ramRunning = false; cpuThread?.Join(); ramThread?.Join(); base.OnFormClosing(e); } } } CSHARP using System; using System.Collections.Generic; using System.Drawing; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; namespace StressTester { public partial class Form1 : Form { private Thread? cpuThread; private Thread? ramThread; private bool cpuRunning = false; private bool ramRunning = false; private DateTime cpuStartTime; private DateTime ramStartTime; private Label cpuTimeLabel; private Label ramTimeLabel; private Button cpuButton; private Button ramButton; private System.Windows.Forms.Timer uiTimer; public Form1() { InitializeComponent(); this.Text = "Stress Tester"; this.Size = new Size(400, 250); this.BackColor = Color.FromArgb(240, 240, 240); cpuButton = new Button() { Text = "Start CPU Load", Location = new Point(20, 20), Size = new Size(150, 40) }; cpuButton.Click += CpuButton_Click; cpuButton.BackColor = Color.LightSteelBlue; cpuButton.FlatStyle = FlatStyle.Flat; this.Controls.Add(cpuButton); cpuTimeLabel = new Label() { Text = "CPU Time: 00:00:00.000", Location = new Point(200, 30), AutoSize = true, ForeColor = Color.DarkBlue, Font = new Font("Segoe UI", 10, FontStyle.Bold) }; this.Controls.Add(cpuTimeLabel); ramButton = new Button() { Text = "Start RAM Load", Location = new Point(20, 80), Size = new Size(150, 40) }; ramButton.Click += RamButton_Click; ramButton.BackColor = Color.LightCoral; ramButton.FlatStyle = FlatStyle.Flat; this.Controls.Add(ramButton); ramTimeLabel = new Label() { Text = "RAM Time: 00:00:00.000", Location = new Point(200, 90), AutoSize = true, ForeColor = Color.DarkRed, Font = new Font("Segoe UI", 10, FontStyle.Bold) }; this.Controls.Add(ramTimeLabel); uiTimer = new System.Windows.Forms.Timer(); uiTimer.Interval = 50; uiTimer.Tick += UiTimer_Tick; uiTimer.Start(); } private void CpuButton_Click(object? sender, EventArgs e) { if (!cpuRunning) { cpuRunning = true; cpuStartTime = DateTime.Now; cpuButton.Text = "Stop CPU Load"; cpuButton.BackColor = Color.LightGreen; cpuThread = new Thread(() => { while (cpuRunning) { Parallel.For(0, Environment.ProcessorCount * 2, _ => { while (cpuRunning) { double x = Math.Pow(new Random().NextDouble(), 3.14); } }); } }); cpuThread.IsBackground = true; cpuThread.Start(); } else { cpuRunning = false; cpuButton.Text = "Start CPU Load"; cpuButton.BackColor = Color.LightSteelBlue; cpuThread?.Join(); } } private void RamButton_Click(object? sender, EventArgs e) { if (!ramRunning) { ramRunning = true; ramStartTime = DateTime.Now; ramButton.Text = "Stop RAM Load"; ramButton.BackColor = Color.LightGreen; ramThread = new Thread(() => { var list = new List<byte[]>(); try { while (ramRunning) { var block = new byte[1000 * 1024 * 1024]; // 1000 MB for (int i = 0; i < block.Length; i += 4096) { block[i] = 1; } list.Add(block); Thread.Sleep(100); } } catch (OutOfMemoryException) { } }); ramThread.IsBackground = true; ramThread.Start(); } else { ramRunning = false; ramButton.Text = "Start RAM Load"; ramButton.BackColor = Color.LightCoral; ramThread?.Join(); } } private void UiTimer_Tick(object? sender, EventArgs e) { if (cpuRunning) { TimeSpan elapsed = DateTime.Now - cpuStartTime; cpuTimeLabel.Text = $"CPU Time: {elapsed:**\\:mm\\:ss\\.fff}"; } else { cpuTimeLabel.Text = "CPU Time: 00:00:00.000"; } if (ramRunning) { TimeSpan elapsed = DateTime.Now - ramStartTime; ramTimeLabel.Text = $"RAM Time: {elapsed:**\\:mm\\:ss\\.fff}"; } else { ramTimeLabel.Text = "RAM Time: 00:00:00.000"; } } protected override void OnFormClosing(FormClosingEventArgs e) { cpuRunning = false; ramRunning = false; cpuThread?.Join(); ramThread?.Join(); base.OnFormClosing(e); } } } GITHUB
using System; using System.Collections.Generic; using System.Drawing; using System.IO; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; namespace StressTester { public partial class Form1 : Form { private CancellationTokenSource _cpuCts; private CancellationTokenSource _ramCts; private CancellationTokenSource _gpuCts; private CancellationTokenSource _diskCts; private DateTime _cpuStartTime; private DateTime _ramStartTime; private DateTime _gpuStartTime; private DateTime _diskStartTime; private Label _cpuTimeLabel; private Label _ramTimeLabel; private Label _gpuTimeLabel; private Label _diskTimeLabel; private Button _cpuToggleButton; private Button _ramToggleButton; private Button _gpuToggleButton; private Button _diskToggleButton; private NumericUpDown _cpuThreadsSelector; private NumericUpDown _ramBlockSizeSelector; private NumericUpDown _gpuLoadSelector; private NumericUpDown _diskBlockSizeSelector; private ProgressBar _ramProgressBar; private ProgressBar _diskProgressBar; private readonly Timer _uiTimer; private Task[] _cpuTasks; private bool _isCpuRunning; private bool _isRamRunning; private bool _isGpuRunning; private bool _isDiskRunning; public Form1() { InitializeComponent(); Text = "Stress Tester"; Size = new Size(600, 450); int y = 20; // CPU controls _cpuToggleButton = new Button { Text = "Start CPU Load", Location = new Point(20, y), Size = new Size(150, 30) }; _cpuToggleButton.Click += OnCpuToggle; Controls.Add(_cpuToggleButton); Controls.Add(new Label { Text = "Threads:", Location = new Point(180, y + 5), AutoSize = true }); _cpuThreadsSelector = new NumericUpDown { Minimum = 1, Maximum = Environment.ProcessorCount * 4, Value = Environment.ProcessorCount, Location = new Point(240, y), Width = 80 }; Controls.Add(_cpuThreadsSelector); _cpuTimeLabel = new Label { Text = "CPU Time: 00:00:00.000", Location = new Point(340, y + 5), AutoSize = true }; Controls.Add(_cpuTimeLabel); y += 70; // RAM controls _ramToggleButton = new Button { Text = "Start RAM Load", Location = new Point(20, y), Size = new Size(150, 30) }; _ramToggleButton.Click += OnRamToggle; Controls.Add(_ramToggleButton); Controls.Add(new Label { Text = "Block MB:", Location = new Point(180, y + 5), AutoSize = true }); _ramBlockSizeSelector = new NumericUpDown { Minimum = 1, Maximum = 1024, Value = 128, Location = new Point(240, y), Width = 80 }; Controls.Add(_ramBlockSizeSelector); _ramTimeLabel = new Label { Text = "RAM Time: 00:00:00.000", Location = new Point(340, y + 5), AutoSize = true }; Controls.Add(_ramTimeLabel); _ramProgressBar = new ProgressBar { Location = new Point(20, y + 35), Size = new Size(540, 20), Maximum = 1024 }; Controls.Add(_ramProgressBar); y += 90; // GPU controls _gpuToggleButton = new Button { Text = "Start GPU Load", Location = new Point(20, y), Size = new Size(150, 30) }; _gpuToggleButton.Click += OnGpuToggle; Controls.Add(_gpuToggleButton); Controls.Add(new Label { Text = "Load %:", Location = new Point(180, y + 5), AutoSize = true }); _gpuLoadSelector = new NumericUpDown { Minimum = 1, Maximum = 100, Value = 50, Location = new Point(240, y), Width = 80 }; Controls.Add(_gpuLoadSelector); _gpuTimeLabel = new Label { Text = "GPU Time: 00:00:00.000", Location = new Point(340, y + 5), AutoSize = true }; Controls.Add(_gpuTimeLabel); y += 70; // Disk controls _diskToggleButton = new Button { Text = "Start Disk Load", Location = new Point(20, y), Size = new Size(150, 30) }; _diskToggleButton.Click += OnDiskToggle; Controls.Add(_diskToggleButton); Controls.Add(new Label { Text = "Block MB:", Location = new Point(180, y + 5), AutoSize = true }); _diskBlockSizeSelector = new NumericUpDown { Minimum = 1, Maximum = 1024, Value = 64, Location = new Point(240, y), Width = 80 }; Controls.Add(_diskBlockSizeSelector); _diskTimeLabel = new Label { Text = "Disk Time: 00:00:00.000", Location = new Point(340, y + 5), AutoSize = true }; Controls.Add(_diskTimeLabel); _diskProgressBar = new ProgressBar { Location = new Point(20, y + 35), Size = new Size(540, 20), Maximum = 1024 }; Controls.Add(_diskProgressBar); // UI timer _uiTimer = new Timer { Interval = 100 }; _uiTimer.Tick += OnUiTimerTick; _uiTimer.Start(); } private void OnCpuToggle(object sender, EventArgs e) { if (!_isCpuRunning) { _isCpuRunning = true; _cpuToggleButton.Text = "Stop CPU Load"; _cpuToggleButton.BackColor = Color.LightGreen; _cpuStartTime = DateTime.Now; _cpuCts = new CancellationTokenSource(); int threads = (int)_cpuThreadsSelector.Value; _cpuTasks = new Task[threads]; for (int i = 0; i < threads; i++) _cpuTasks[i] = Task.Run(() => RunCpuLoad(_cpuCts.Token), _cpuCts.Token); } else { _isCpuRunning = false; _cpuToggleButton.Text = "Start CPU Load"; _cpuToggleButton.BackColor = SystemColors.Control; _cpuCts.Cancel(); Task.WaitAll(_cpuTasks); } } private void RunCpuLoad(CancellationToken token) { var rand = new Random(Guid.NewGuid().GetHashCode()); while (!token.IsCancellationRequested) { double v = rand.NextDouble(); Math.Pow(v, 3.14); } } private void OnRamToggle(object sender, EventArgs e) { if (!_isRamRunning) { _isRamRunning = true; _ramToggleButton.Text = "Stop RAM Load"; _ramToggleButton.BackColor = Color.LightGreen; _ramStartTime = DateTime.Now; _ramCts = new CancellationTokenSource(); int size = (int)_ramBlockSizeSelector.Value; Task.Run(() => RunRamLoad(size, _ramCts.Token), _ramCts.Token); } else { _isRamRunning = false; _ramToggleButton.Text = "Start RAM Load"; _ramToggleButton.BackColor = SystemColors.Control; _ramCts.Cancel(); } } private void RunRamLoad(int sizeMb, CancellationToken token) { var list = new List<byte[]>(); int used = 0; try { while (!token.IsCancellationRequested) { var block = new byte[sizeMb * 1024 * 1024]; for (int i = 0; i < block.Length; i += Environment.SystemPageSize) block[i] = 0xFF; list.Add(block); used += sizeMb; UpdateRamProgress(used); } } catch (OutOfMemoryException) { } finally { list.Clear(); GC.Collect(); } } private void OnGpuToggle(object sender, EventArgs e) { if (!_isGpuRunning) { _isGpuRunning = true; _gpuToggleButton.Text = "Stop GPU Load"; _gpuToggleButton.BackColor = Color.LightGreen; _gpuStartTime = DateTime.Now; _gpuCts = new CancellationTokenSource(); int intensity = (int)_gpuLoadSelector.Value; Task.Run(() => RunGpuLoad(intensity, _gpuCts.Token), _gpuCts.Token); } else { _isGpuRunning = false; _gpuToggleButton.Text = "Start GPU Load"; _gpuToggleButton.BackColor = SystemColors.Control; _gpuCts.Cancel(); } } private void RunGpuLoad(int intensity, CancellationToken token) { int width = 256, height = 256; using var bmp = new Bitmap(width, height); var rnd = new Random(); while (!token.IsCancellationRequested) { using var gfx = Graphics.FromImage(bmp); for (int i = 0; i < intensity; i++) { int x = rnd.Next(width), y = rnd.Next(height); bmp.SetPixel(x, y, Color.FromArgb(rnd.Next())); } } } private void OnDiskToggle(object sender, EventArgs e) { if (!_isDiskRunning) { _isDiskRunning = true; _diskToggleButton.Text = "Stop Disk Load"; _diskToggleButton.BackColor = Color.LightGreen; _diskStartTime = DateTime.Now; _diskCts = new CancellationTokenSource(); int block = (int)_diskBlockSizeSelector.Value; Task.Run(() => RunDiskLoad(block, _diskCts.Token), _diskCts.Token); } else { _isDiskRunning = false; _diskToggleButton.Text = "Start Disk Load"; _diskToggleButton.BackColor = SystemColors.Control; _diskCts.Cancel(); } } private void RunDiskLoad(int blockMb, CancellationToken token) { string path = Path.Combine(Path.GetTempPath(), "disk_stress_test.tmp"); int written = 0; try { using (var fs = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.None)) { var buffer = new byte[blockMb * 1024 * 1024]; while (!token.IsCancellationRequested) { fs.Write(buffer, 0, buffer.Length); fs.Flush(); written += blockMb; UpdateDiskProgress(written); } } } finally { if (File.Exists(path)) CSHARP using System; using System.Collections.Generic; using System.Drawing; using System.IO; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; namespace StressTester { public partial class Form1 : Form { private CancellationTokenSource _cpuCts; private CancellationTokenSource _ramCts; private CancellationTokenSource _gpuCts; private CancellationTokenSource _diskCts; private DateTime _cpuStartTime; private DateTime _ramStartTime; private DateTime _gpuStartTime; private DateTime _diskStartTime; private Label _cpuTimeLabel; private Label _ramTimeLabel; private Label _gpuTimeLabel; private Label _diskTimeLabel; private Button _cpuToggleButton; private Button _ramToggleButton; private Button _gpuToggleButton; private Button _diskToggleButton; private NumericUpDown _cpuThreadsSelector; private NumericUpDown _ramBlockSizeSelector; private NumericUpDown _gpuLoadSelector; private NumericUpDown _diskBlockSizeSelector; private ProgressBar _ramProgressBar; private ProgressBar _diskProgressBar; private readonly Timer _uiTimer; private Task[] _cpuTasks; private bool _isCpuRunning; private bool _isRamRunning; private bool _isGpuRunning; private bool _isDiskRunning; public Form1() { InitializeComponent(); Text = "Stress Tester"; Size = new Size(600, 450); int y = 20; // CPU controls _cpuToggleButton = new Button { Text = "Start CPU Load", Location = new Point(20, y), Size = new Size(150, 30) }; _cpuToggleButton.Click += OnCpuToggle; Controls.Add(_cpuToggleButton); Controls.Add(new Label { Text = "Threads:", Location = new Point(180, y + 5), AutoSize = true }); _cpuThreadsSelector = new NumericUpDown { Minimum = 1, Maximum = Environment.ProcessorCount * 4, Value = Environment.ProcessorCount, Location = new Point(240, y), Width = 80 }; Controls.Add(_cpuThreadsSelector); _cpuTimeLabel = new Label { Text = "CPU Time: 00:00:00.000", Location = new Point(340, y + 5), AutoSize = true }; Controls.Add(_cpuTimeLabel); y += 70; // RAM controls _ramToggleButton = new Button { Text = "Start RAM Load", Location = new Point(20, y), Size = new Size(150, 30) }; _ramToggleButton.Click += OnRamToggle; Controls.Add(_ramToggleButton); Controls.Add(new Label { Text = "Block MB:", Location = new Point(180, y + 5), AutoSize = true }); _ramBlockSizeSelector = new NumericUpDown { Minimum = 1, Maximum = 1024, Value = 128, Location = new Point(240, y), Width = 80 }; Controls.Add(_ramBlockSizeSelector); _ramTimeLabel = new Label { Text = "RAM Time: 00:00:00.000", Location = new Point(340, y + 5), AutoSize = true }; Controls.Add(_ramTimeLabel); _ramProgressBar = new ProgressBar { Location = new Point(20, y + 35), Size = new Size(540, 20), Maximum = 1024 }; Controls.Add(_ramProgressBar); y += 90; // GPU controls _gpuToggleButton = new Button { Text = "Start GPU Load", Location = new Point(20, y), Size = new Size(150, 30) }; _gpuToggleButton.Click += OnGpuToggle; Controls.Add(_gpuToggleButton); Controls.Add(new Label { Text = "Load %:", Location = new Point(180, y + 5), AutoSize = true }); _gpuLoadSelector = new NumericUpDown { Minimum = 1, Maximum = 100, Value = 50, Location = new Point(240, y), Width = 80 }; Controls.Add(_gpuLoadSelector); _gpuTimeLabel = new Label { Text = "GPU Time: 00:00:00.000", Location = new Point(340, y + 5), AutoSize = true }; Controls.Add(_gpuTimeLabel); y += 70; // Disk controls _diskToggleButton = new Button { Text = "Start Disk Load", Location = new Point(20, y), Size = new Size(150, 30) }; _diskToggleButton.Click += OnDiskToggle; Controls.Add(_diskToggleButton); Controls.Add(new Label { Text = "Block MB:", Location = new Point(180, y + 5), AutoSize = true }); _diskBlockSizeSelector = new NumericUpDown { Minimum = 1, Maximum = 1024, Value = 64, Location = new Point(240, y), Width = 80 }; Controls.Add(_diskBlockSizeSelector); _diskTimeLabel = new Label { Text = "Disk Time: 00:00:00.000", Location = new Point(340, y + 5), AutoSize = true }; Controls.Add(_diskTimeLabel); _diskProgressBar = new ProgressBar { Location = new Point(20, y + 35), Size = new Size(540, 20), Maximum = 1024 }; Controls.Add(_diskProgressBar); // UI timer _uiTimer = new Timer { Interval = 100 }; _uiTimer.Tick += OnUiTimerTick; _uiTimer.Start(); } private void OnCpuToggle(object sender, EventArgs e) { if (!_isCpuRunning) { _isCpuRunning = true; _cpuToggleButton.Text = "Stop CPU Load"; _cpuToggleButton.BackColor = Color.LightGreen; _cpuStartTime = DateTime.Now; _cpuCts = new CancellationTokenSource(); int threads = (int)_cpuThreadsSelector.Value; _cpuTasks = new Task[threads]; for (int i = 0; i < threads; i++) _cpuTasks[i] = Task.Run(() => RunCpuLoad(_cpuCts.Token), _cpuCts.Token); } else { _isCpuRunning = false; _cpuToggleButton.Text = "Start CPU Load"; _cpuToggleButton.BackColor = SystemColors.Control; _cpuCts.Cancel(); Task.WaitAll(_cpuTasks); } } private void RunCpuLoad(CancellationToken token) { var rand = new Random(Guid.NewGuid().GetHashCode()); while (!token.IsCancellationRequested) { double v = rand.NextDouble(); Math.Pow(v, 3.14); } } private void OnRamToggle(object sender, EventArgs e) { if (!_isRamRunning) { _isRamRunning = true; _ramToggleButton.Text = "Stop RAM Load"; _ramToggleButton.BackColor = Color.LightGreen; _ramStartTime = DateTime.Now; _ramCts = new CancellationTokenSource(); int size = (int)_ramBlockSizeSelector.Value; Task.Run(() => RunRamLoad(size, _ramCts.Token), _ramCts.Token); } else { _isRamRunning = false; _ramToggleButton.Text = "Start RAM Load"; _ramToggleButton.BackColor = SystemColors.Control; _ramCts.Cancel(); } } private void RunRamLoad(int sizeMb, CancellationToken token) { var list = new List<byte[]>(); int used = 0; try { while (!token.IsCancellationRequested) { var block = new byte[sizeMb * 1024 * 1024]; for (int i = 0; i < block.Length; i += Environment.SystemPageSize) block[i] = 0xFF; list.Add(block); used += sizeMb; UpdateRamProgress(used); } } catch (OutOfMemoryException) { } finally { list.Clear(); GC.Collect(); } } private void OnGpuToggle(object sender, EventArgs e) { if (!_isGpuRunning) { _isGpuRunning = true; _gpuToggleButton.Text = "Stop GPU Load"; _gpuToggleButton.BackColor = Color.LightGreen; _gpuStartTime = DateTime.Now; _gpuCts = new CancellationTokenSource(); int intensity = (int)_gpuLoadSelector.Value; Task.Run(() => RunGpuLoad(intensity, _gpuCts.Token), _gpuCts.Token); } else { _isGpuRunning = false; _gpuToggleButton.Text = "Start GPU Load"; _gpuToggleButton.BackColor = SystemColors.Control; _gpuCts.Cancel(); } } private void RunGpuLoad(int intensity, CancellationToken token) { int width = 256, height = 256; using var bmp = new Bitmap(width, height); var rnd = new Random(); while (!token.IsCancellationRequested) { using var gfx = Graphics.FromImage(bmp); for (int i = 0; i < intensity; i++) { int x = rnd.Next(width), y = rnd.Next(height); bmp.SetPixel(x, y, Color.FromArgb(rnd.Next())); } } } private void OnDiskToggle(object sender, EventArgs e) { if (!_isDiskRunning) { _isDiskRunning = true; _diskToggleButton.Text = "Stop Disk Load"; _diskToggleButton.BackColor = Color.LightGreen; _diskStartTime = DateTime.Now; _diskCts = new CancellationTokenSource(); int block = (int)_diskBlockSizeSelector.Value; Task.Run(() => RunDiskLoad(block, _diskCts.Token), _diskCts.Token); } else { _isDiskRunning = false; _diskToggleButton.Text = "Start Disk Load"; _diskToggleButton.BackColor = SystemColors.Control; _diskCts.Cancel(); } } private void RunDiskLoad(int blockMb, CancellationToken token) { string path = Path.Combine(Path.GetTempPath(), "disk_stress_test.tmp"); int written = 0; try { using (var fs = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.None)) { var buffer = new byte[blockMb * 1024 * 1024]; while (!token.IsCancellationRequested) { fs.Write(buffer, 0, buffer.Length); fs.Flush(); written += blockMb; UpdateDiskProgress(written); } } } finally { if (File.Exists(path))
yoona, ну вообще в виндоус они не такие как в линукс , виндоус не убивает процессы как линукс если память заканчивается , но да возможно OOM киллеры сработают